decklight 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/PLATFORM.md +666 -0
  2. package/README.md +224 -150
  3. package/SPEC.md +732 -886
  4. package/cli/agent-review.mjs +245 -0
  5. package/cli/agents.mjs +25 -5
  6. package/cli/associate.mjs +12 -12
  7. package/cli/audit.mjs +42 -10
  8. package/cli/banner.mjs +41 -17
  9. package/cli/bundle-audio.mjs +183 -0
  10. package/cli/bundle.mjs +383 -31
  11. package/cli/cast.mjs +7 -7
  12. package/cli/check.mjs +961 -0
  13. package/cli/clone-deck.mjs +179 -0
  14. package/cli/commands.mjs +345 -0
  15. package/cli/comments.mjs +64 -18
  16. package/cli/commit-flow.mjs +44 -19
  17. package/cli/commit-message.mjs +51 -74
  18. package/cli/commit-split.mjs +601 -0
  19. package/cli/deck-refs.mjs +59 -0
  20. package/cli/deck-routes.mjs +67 -0
  21. package/cli/deckfile.mjs +3 -5
  22. package/cli/decklight.mjs +68 -289
  23. package/cli/design-system-deps.mjs +209 -0
  24. package/cli/design-system-edit.mjs +194 -0
  25. package/cli/design-system-refs.mjs +409 -0
  26. package/cli/design-system.mjs +429 -0
  27. package/cli/doctor.mjs +115 -0
  28. package/cli/edit-git.mjs +353 -0
  29. package/cli/edit-handover.mjs +445 -0
  30. package/cli/edit-look.mjs +388 -0
  31. package/cli/edit-slides.mjs +683 -0
  32. package/cli/edit.mjs +2126 -842
  33. package/cli/enhance.mjs +483 -0
  34. package/cli/extension.mjs +10 -10
  35. package/cli/font-refs.mjs +273 -0
  36. package/cli/font.mjs +246 -0
  37. package/cli/git-tree.mjs +1 -1
  38. package/cli/git.mjs +65 -11
  39. package/cli/import.mjs +56 -10
  40. package/cli/init.mjs +400 -234
  41. package/cli/library.mjs +127 -0
  42. package/cli/loader.mjs +3 -1
  43. package/cli/marketplace.mjs +215 -21
  44. package/cli/narrate.mjs +176 -0
  45. package/cli/open-browser.mjs +63 -0
  46. package/cli/open.mjs +943 -0
  47. package/cli/pdf.mjs +41 -13
  48. package/cli/pkg.mjs +44 -2
  49. package/cli/plugin.mjs +43 -41
  50. package/cli/port-conflict.mjs +53 -23
  51. package/cli/pptx-export.mjs +71 -26
  52. package/cli/publish.mjs +8 -4
  53. package/cli/qr.mjs +1 -1
  54. package/cli/record.mjs +14 -12
  55. package/cli/remote.mjs +11 -11
  56. package/cli/restore.mjs +11 -4
  57. package/cli/review-ref.mjs +125 -0
  58. package/cli/review-remote.mjs +92 -48
  59. package/cli/review-routes.mjs +254 -0
  60. package/cli/review-store.mjs +47 -7
  61. package/cli/review-submit.mjs +47 -57
  62. package/cli/runtime-link.mjs +560 -0
  63. package/cli/serve.mjs +235 -44
  64. package/cli/setup.mjs +112 -0
  65. package/cli/sign.mjs +1 -1
  66. package/cli/skill-content.mjs +190 -33
  67. package/cli/skills.mjs +107 -24
  68. package/cli/start.mjs +110 -0
  69. package/cli/supervise.mjs +6 -6
  70. package/cli/theme-refs.mjs +515 -0
  71. package/cli/theme.mjs +181 -137
  72. package/cli/trust.mjs +83 -0
  73. package/cli/units.mjs +39 -42
  74. package/cli/update-check.mjs +1 -5
  75. package/cli/upgrade.mjs +194 -28
  76. package/cli/upstream.mjs +4 -3
  77. package/cli/util.mjs +4 -4
  78. package/cli/wizard.mjs +6 -6
  79. package/dist/build-info.json +1 -1
  80. package/dist/decklight.css +1126 -49
  81. package/dist/decklight.js +212 -115
  82. package/dist/decklight.js.map +4 -4
  83. package/docs/GLOSSARY.md +141 -0
  84. package/docs/architecture.svg +17 -17
  85. package/package.json +4 -2
  86. package/themes/README.md +9 -8
  87. package/themes/reveal-solarized.css +10 -0
  88. package/tools/args.mjs +20 -0
  89. package/tools/atomic-write.mjs +48 -0
  90. package/tools/brand-palette.mjs +717 -0
  91. package/tools/bridge.mjs +1 -1
  92. package/tools/build-groups.mjs +42 -0
  93. package/tools/color.mjs +48 -0
  94. package/tools/deck-html.mjs +396 -11
  95. package/tools/design-system-format.mjs +753 -0
  96. package/tools/elevenlabs-tts.mjs +110 -17
  97. package/tools/exec.mjs +35 -2
  98. package/tools/extension-check.mjs +31 -7
  99. package/tools/font-format.mjs +190 -0
  100. package/tools/font-stacks.mjs +24 -0
  101. package/tools/gemini-tts.mjs +3 -0
  102. package/tools/lipsync-config.mjs +103 -0
  103. package/tools/lipsync-engines.mjs +205 -2
  104. package/tools/lipsync-server.mjs +264 -41
  105. package/tools/lipsync.mjs +37 -18
  106. package/tools/local-voice.mjs +32 -42
  107. package/tools/narration-manifest.mjs +196 -0
  108. package/tools/narration-synth.mjs +416 -0
  109. package/tools/pptx.mjs +776 -19
  110. package/tools/publish-targets.mjs +1 -1
  111. package/tools/publish-voices.mjs +3 -3
  112. package/tools/recording-impact.mjs +7 -3
  113. package/tools/render-theme.mjs +33 -0
  114. package/tools/review-anchor.mjs +28 -12
  115. package/tools/semver.mjs +40 -0
  116. package/tools/sentences.mjs +180 -0
  117. package/tools/shot.mjs +14 -7
  118. package/tools/site-voices.mjs +232 -0
  119. package/tools/template-theme.mjs +1 -1
  120. package/tools/test-impact.mjs +19 -10
  121. package/tools/theme-check.mjs +30 -3
  122. package/tools/tts-cache.mjs +4 -3
  123. package/tools/tts-engines.mjs +38 -20
  124. package/tools/tts-setup.mjs +7 -7
  125. package/tools/video-options.mjs +34 -0
  126. package/tools/video.mjs +461 -48
  127. package/tools/voiceover-server.mjs +185 -104
  128. package/tools/voiceover.mjs +119 -261
  129. package/tools/zip.mjs +1 -1
  130. package/cli/dev.mjs +0 -623
  131. package/cli/present.mjs +0 -853
  132. package/cli/review.mjs +0 -361
  133. package/tools/publish-site-voices.mjs +0 -75
@@ -25,9 +25,11 @@ import { PKG_ROOT, PKG } from './pkg.mjs';
25
25
  export { PKG_ROOT, PKG };
26
26
 
27
27
  /**
28
- * The authoring contract, sliced from SPEC.md through JS_API (everything an
29
- * agent needs to write slides), dropping the repo-layout/tooling section
30
- * that only matters to Decklight's own contributors.
28
+ * The authoring contract: SPEC.md up to REPO_LAYOUT, which only matters to
29
+ * Decklight's own contributors. The platform contract (the marketplace and
30
+ * the library's units) lives in PLATFORM.md, which SPEC.md points at and the
31
+ * skill does not install: an agent writing slides rarely needs it, and it
32
+ * was a third of every project's reference.md.
31
33
  */
32
34
  export function referenceDoc() {
33
35
  const spec = fs.readFileSync(path.join(PKG_ROOT, 'SPEC.md'), 'utf8');
@@ -40,20 +42,38 @@ export function referenceDoc() {
40
42
  * progressive-disclosure body that points at `referenceHref` (a path
41
43
  * relative to the SKILL.md) for the full contract.
42
44
  */
45
+ /**
46
+ * The version a skill was written by, as a comment the file carries — read
47
+ * back by `decklight skills` (a skill older than this build is refreshed
48
+ * without --force) and by write mode's startup (which names one that is
49
+ * older than the install, since an agent reading it reads an old contract).
50
+ */
51
+ export const SKILL_STAMP = (version = PKG.version) => `<!-- decklight skill ${version} -->`;
52
+ export function skillVersionOf(text) {
53
+ const m = /<!-- decklight skill (\d+\.\d+\.\d+[^\s]*) -->/.exec(String(text ?? ''));
54
+ return m ? m[1] : null;
55
+ }
56
+
43
57
  export function claudeSkillMd(referenceHref = 'reference.md') {
44
58
  return `---
45
59
  name: decklight
46
- description: Author and edit Decklight presentations — single-file HTML decks with Keynote-style builds, theme-aware SVG diagrams, 46 built-in themes, truthful terminal recordings, and live TTS narration. Use whenever creating or editing a Decklight deck (a .html file with a <div class="decklight"> of <section> slides) in this project.
60
+ description: Author and edit Decklight presentations — single-file HTML decks with Keynote-style builds, theme-aware SVG diagrams, 46 built-in themes, a company's design system (its templates, brand themes and roles), truthful terminal recordings, and live TTS narration. Use whenever creating or editing a Decklight deck (a .html file with a <div class="decklight"> of <section> slides) in this project.
47
61
  ---
62
+ ${SKILL_STAMP()}
48
63
 
49
- Decklight decks are one HTML file: no build step, no bundler, no server to
50
- author. A deck is \`<div class="decklight">\` containing \`<section>\` slides;
51
- the runtime is one JS file + one CSS file + one theme CSS file.
64
+ Decklight decks are one HTML file of slides: no build step, no bundler. A deck
65
+ is \`<div class="decklight">\` containing \`<section>\` slides, plus one JSON
66
+ configuration block (\`<script type="application/json" data-decklight-config>\`)
67
+ — and nothing that executes: no runtime in the file, no \`Decklight.init\` call.
68
+ \`decklight <deck>\` (write mode or \`--no-trust\`) adds the installed runtime as it
69
+ serve it, and \`decklight bundle\` embeds it into one self-contained file to hand
70
+ over. Write slides and configuration; never write boilerplate.
52
71
 
53
72
  **Full authoring contract**: read [${referenceHref}](${referenceHref}) in this same
54
73
  skill directory before authoring or editing a slide — SLIDE_DENSITY is how much goes on
55
74
  one, COMPARISON_SLIDES is the worked comparison (pros/cons) slide, and past those it covers builds,
56
- speaker notes segmentation (⟨CLICK⟩), SVG diagrams, theming, motion, code
75
+ speaker notes segmentation ([click]), SLIDE_SOURCES (where a slide got what it says),
76
+ SVG diagrams, theming, motion, code
57
77
  blocks, LaTeX math, terminal recordings, narration, and the public JS API. It's sliced
58
78
  straight from Decklight's SPEC.md (v${PKG.version}), so it won't drift from
59
79
  the installed runtime's actual behavior — trust it over prior training.
@@ -70,15 +90,79 @@ with a build and notes already wired):
70
90
  </div>
71
91
  \`\`\`
72
92
 
93
+ A long deck can be split into chapters with \`data-module\` on the section that
94
+ starts one — every slide after it belongs to that chapter until the next marker.
95
+ The deck shows the current chapter in its chrome and shows them as a foldable
96
+ outline in the slide finder (**G**). Use it for a course or a multi-module deck; a
97
+ fifteen-slide talk does not need chapters:
98
+
99
+ \`\`\`html
100
+ <section data-module="Foundations"><h2>Foundations</h2></section>
101
+ \`\`\`
102
+
103
+ Two asides, and they are not the same thing. \`notes\` is what the speaker SAYS.
104
+ \`sources\` is where the slide got what it says — named facts and links a reader
105
+ can follow, hidden on the slide and opened with **I**. Add it when a slide makes
106
+ a claim worth attributing; leave it off when it does not:
107
+
108
+ \`\`\`html
109
+ <aside class="sources">
110
+ <dl><dt>owner</dt><dd>platform-team</dd><dt>reviewed</dt><dd>2026-08-14</dd></dl>
111
+ <ul><li><a href="https://…/KIP-98">KIP-98</a> — the original proposal</li></ul>
112
+ </aside>
113
+ \`\`\`
114
+
115
+ **Cite as you build.** When a deck is made from material (a PDF, a web page, a
116
+ document, a transcript, files in a repository) the user gave you or you looked
117
+ up, every slide that states something taken from it gets its \`sources\` aside
118
+ **while you write the slide**, not in a pass at the end, when you no longer
119
+ know which page a number came from. One link per source the slide stands on:
120
+
121
+ - **Name the part, not just the source**, whenever the source is bigger than
122
+ what you used: the pages of a PDF (\`report.pdf#page=12\`, note \`pp. 12–14\`),
123
+ the section of a web page (its \`#anchor\`, or a text fragment
124
+ \`#:~:text=first%20words\`), the heading of a document, the lines of a file
125
+ (\`src/server.ts\`, note \`lines 40–88\`), the minutes of a recording. The link
126
+ opens where you read; the note says how much.
127
+ - **A local file is linked by its path relative to the deck**, so the link
128
+ still opens after the deck moves with it.
129
+ - **Cite only what you actually opened and read.** Never a source you did not
130
+ read, never a page you did not read, and never a link you reconstructed from
131
+ memory. A slide built from your own general knowledge carries no link that
132
+ pretends otherwise: leave it unsourced and say so in the report below.
133
+
134
+ \`\`\`html
135
+ <aside class="sources">
136
+ <ul>
137
+ <li><a href="docs/annual-report-2025.pdf#page=12">Annual report 2025</a> — pp. 12–14, revenue by region</li>
138
+ <li><a href="https://example.com/pricing#enterprise">Pricing page</a> — Enterprise tier only</li>
139
+ </ul>
140
+ </aside>
141
+ \`\`\`
142
+
143
+ **Then tell the user what the deck stands on.** When you finish a deck (or a
144
+ batch of slides), end your reply with a sources report, so they can check the
145
+ deck against its material without opening every slide:
146
+
147
+ - each source you used, with the parts of it you used (pages, sections,
148
+ headings, lines) and the slides that cite it;
149
+ - each source you were given but did not use, and why (off topic, unreadable,
150
+ a scanned PDF with no text layer);
151
+ - each slide that makes claims with no source behind it, so the user knows
152
+ which ones rest on your general knowledge.
153
+
154
+ Keep the report in your reply, not on a slide: the deck already carries the same
155
+ facts, per slide, in its \`sources\` asides.
156
+
73
157
  **CLI** (\`npx decklight@latest <command>\`, no install needed):
74
- - \`decklight author deck.html\` — the whole authoring loop: serve with live reload; **E** in the browser edits speaker notes back into the file
75
- - \`decklight cast script.term.yaml\` — record a truthful terminal cast in a real PTY, for \`<div class="terminal">\` (this records a TERMINAL; \`decklight record\` records the author's voice)
158
+ - \`decklight deck.html\` — the whole authoring loop: serve with live reload; editing is on in the browser — text, pictures, layouts and speaker notes are written back into the file
159
+ - \`decklight cast script.term.yaml\` — record a truthful terminal cast in a real PTY, for \`<div class="terminal">\` (this records a TERMINAL; \`decklight narrate --mic\` records the author's voice)
76
160
  - \`decklight bundle deck.html --themes all\` — flatten into one self-contained file to hand off or publish
77
161
  - \`decklight pdf deck.html\` — render every slide to a PDF, and report the ones that overflow
78
162
  - \`decklight pptx deck.html\` — a PowerPoint file for whoever asks for one: every slide a picture, the notes real notes (lossy on purpose)
79
- - \`decklight tts\` — live voice bridge so the deck can narrate itself on the fly
80
- - \`decklight record deck.html\` — record the narration in the author's OWN voice: the deck shows one \`⟨CLICK⟩\` beat at a time and \`→\` ends it, writing \`slide-NN-KK.wav\` per beat so the recording paces the builds (play it back with \`narration: { files: 'voiceover', ext: 'wav', segments: true }\`)
81
- - \`decklight review deck.html\` / \`decklight comments deck.html\` — reviewer comments on slides, stored append-only in \`<deck>.review.jsonl\` and carried by git; a comment records the slide's title and a fingerprint of its text, so it finds its slide again after the deck moves and says so when the slide changed or is gone; \`decklight review submit deck.html\` pushes the review to a \`review/<you>-<date>\` branch (one file, never the reviewer's own commits; \`--pr\` opens the pull request), and the author hears about waiting reviews at \`decklight author\` startup, in the M overlay, and via \`decklight comments deck.html --incoming\`
163
+ - \`decklight setup voice\` — set up live narration once (which engine, what it needs); every deck opened after uses it
164
+ - \`decklight narrate --mic deck.html\` — record the narration in the author's OWN voice: the deck shows one \`[click]\` beat at a time and \`→\` ends it, writing \`slide-NN-KK.wav\` per beat so the recording paces the builds (play it back with \`narration: { files: 'voiceover', ext: 'wav', segments: true }\`)
165
+ - \`decklight deck.html --no-trust\` (M to comment) / \`decklight comments deck.html\` — reviewer comments on slides, stored append-only in \`<deck>.review.jsonl\` and carried by git; a comment records the slide's title and a fingerprint of its text, so it finds its slide again after the deck moves and says so when the slide changed or is gone; \`decklight comments submit deck.html\` pushes the review to a \`review/<you>-<date>\` branch (one file, never the reviewer's own commits; \`--pr\` opens the pull request), and the author hears about waiting reviews at startup in write mode, in the M overlay, and via \`decklight comments deck.html --incoming\`
82
166
  - \`decklight skills\` — regenerate this skill after upgrading Decklight
83
167
 
84
168
  **Render the deck before you call a slide done.** Content that exceeds a slide
@@ -95,7 +179,9 @@ or move the detail into the notes. Run it after each batch of slides rather
95
179
  than once at the end — and note that overflow is the *late* failure. A slide
96
180
  that fits can still be too crowded to present from; prefer ~3–4 bullets or ~2
97
181
  short paragraphs per column, and one idea per slide, over anything that merely
98
- fits (SLIDE_DENSITY).
182
+ fits (SLIDE_DENSITY). \`npx decklight@latest check deck.html\` names those
183
+ too: a slide past that budget is reported \`crowded\` with the count that
184
+ tipped it (a warning, never a failed run); split it rather than shrink it.
99
185
 
100
186
  **For a comparison slide, use \`data-layout="split"\` — and do not also write
101
187
  your own column flexbox.** Two sibling blocks become the columns, a third
@@ -107,28 +193,83 @@ COMPARISON_SLIDES has the markup. The engine marks the mixed state
107
193
  same \`decklight pdf\` run above names such slides — one render check catches
108
194
  both.
109
195
 
196
+ **A diagram line that draws is one stroke, with everything on it.** A
197
+ \`data-build="draw"\` container draws its strokes in; an arrowhead is a
198
+ \`<marker>\` on the stroke's \`marker-end\` (it rides the tip), a dashed line is
199
+ \`stroke-dasharray\` on the stroke (it draws dashed, start to finish), and a
200
+ line in stages is \`data-draw-stops\`. A separate arrowhead shape, or dashes set
201
+ from a stylesheet class, do not draw as one: the head stands at the end before
202
+ the line arrives, the dashes snap in when it ends. Group a line with the box it
203
+ points at when they should arrive together; keep it a direct child when the
204
+ line is its own beat. The engine adds \`.draw-head\` and \`.draw-mask\` nodes
205
+ beside a drawing stroke in the browser: they are not in the file, so never
206
+ copy them from the rendered DOM into the deck. SVG_DIAGRAMS has the rules.
207
+
208
+ **On a deck that uses a design system, fill its templates' slots — never
209
+ recreate a template's structure by hand.** A slide names a template and
210
+ supplies one element per slot (\`<section data-template="acme/section-divider">\`
211
+ with \`<h2 data-slot="title">\`); the structure comes from the design system
212
+ when the deck renders, so copied markup never updates with it.
213
+ \`decklight design-system templates acme@<marketplace>\` lists the templates and
214
+ their slots (\`*\` required); \`decklight check\` names a missing template or slot,
215
+ a slot filled twice and a required one left empty (DESIGN_SYSTEMS in the reference).
216
+
217
+ **On a deck held to a design system's brand, colour through its roles.** A
218
+ design system that ships a palette and its own themes holds the deck to them
219
+ (\`"brandThemesOnly"\` unset): the deck opens only on the brand's themes, and
220
+ every colour a slide names is the brand's. When it declares roles, write
221
+ \`var(--acme-color-text-accent)\` (\`--<prefix>color-<role>\`, the roles are in
222
+ \`design-system.json\`), never a swatch (\`var(--acme-blue-600)\`), the theme
223
+ contract (\`var(--accent)\`, \`var(--d-fill-2)\`), one of its other tokens, or a
224
+ literal: each theme sets every role, so \`T\` recolours the deck and nothing
225
+ drifts off-brand. A diagram fill the contract maps to a role is written as that
226
+ role and still nests like its slot. \`decklight check\` says \`off-role\` (a
227
+ colour that is not a role, with the nearest one), \`off-palette-literal\` (on a
228
+ brand without roles) and \`theme-off-brand\` (a configured theme outside the
229
+ brand); \`"brandThemesOnly": false\` is the author's way out, never yours to
230
+ add (BRAND_PALETTE and DESIGN_SYSTEM_ROLES in the reference).
231
+
110
232
  Speaker notes drive both live narration and the transcript/caption
111
233
  features, so write them even for decks that will only ever be read: split
112
- multi-beat notes with a bare \`⟨CLICK⟩\` line so narration and build steps
113
- stay in sync (PRESENTING in the reference).
114
-
115
- **Commit your own changes when an authoring server is running.** \`decklight
116
- author\` auto-commits the deck, but on a timer and under a generic \`autosave\`
117
- message — it cannot tell your edits from anyone else's, because it did not
118
- start you. When you finish one logical change, say so:
234
+ multi-beat notes with a bare \`[click]\` line so narration and build steps
235
+ stay in sync (PRESENTING in the reference). Where an idea needs a moment to
236
+ land, put \`[pause]\` there (\`[long pause]\` for twice that) and it is never
237
+ said: ElevenLabs v4/v3 holds it itself, in its own breath; for every other
238
+ voice decklight holds it (two beat pauses, 1s by default). Use it sparingly —
239
+ at the few moments that earn it. Write the markers in square brackets; the
240
+ older \`<pause>\` and \`⟨PAUSE⟩\` spellings still read the same.
241
+ Any other bracketed words — \`[whispers]\`, \`[laughs]\` — are audio tags for
242
+ ElevenLabs v4 (the default ElevenLabs model) and v3; every other voice leaves
243
+ them out, and captions never show them, so the notes read the same anywhere.
244
+
245
+ **Prompting ElevenLabs v4 in the notes.** When ElevenLabs narrates, the notes
246
+ ARE the prompt ([its best practices](https://elevenlabs.io/docs/overview/capabilities/text-to-speech/best-practices#prompting-eleven-v4)):
247
+ natural sentences and punctuation do most of the work; a tag goes right before
248
+ what it directs (\`[whispers]\`, \`[curious]\`, \`[laughs]\`), suits the voice, and
249
+ earns its place, one or two a slide; pauses are \`[pause]\`, never \`<break>\`.
250
+ \`decklight enhance deck.html --slides 3\` adds tags with ElevenLabs' own prompt
251
+ and writes only answers that kept every word, \`[click]\` and \`[pause]\`. Editing
252
+ by hand, follow the same rules: add tags, never reword the author's script.
253
+
254
+ **Notes are said, not read.** Write them as sentences a person would say out
255
+ loud — "And if you fluff a line, just press Backspace to take it again", not
256
+ "Fluffed a line? Backspace retakes it." — and say symbols as words ("Command",
257
+ not "⌘"). To rewrite terse notes that way when asked, \`decklight enhance
258
+ deck.html --spoken --slides 3\` does it with the same checks on the beats and
259
+ the pauses.
260
+
261
+ **Commit your own changes when an edit server is running.** It snapshots
262
+ silently and commits only when told; you are not an agent it started, so
263
+ after each logical change:
119
264
 
120
265
  \`\`\`sh
121
- curl -sf -X POST localhost:8788/edit/commit \\
122
- -H 'content-type: application/json' \\
123
- -d '{"message":"split the crowded video slides"}'
266
+ curl -sf -X POST localhost:8788/deck/edit/commit \\
267
+ -H 'content-type: application/json' -d '{"message":"split the crowded video slides"}'
124
268
  \`\`\`
125
269
 
126
- One call per logical change, with a subject describing THAT change — not
127
- \"updated the deck\". It commits only the deck file, and does nothing when
128
- nothing changed, so an extra call is harmless. If the port is not listening
129
- there is no authoring server: skip it silently and carry on, never start one
130
- yourself. This is what makes a history someone can read afterwards, instead
131
- of a wall of identical timer commits.
270
+ A subject for THAT change, never "updated the deck". It commits only the deck
271
+ and is a no-op when nothing changed. Nothing listening on the port: skip it
272
+ silently, and never start a server yourself.
132
273
 
133
274
  **That history is readable, and it is how a bad edit is undone.** \`decklight
134
275
  history deck.html\` lists every commit that touched the deck and marks the ones
@@ -152,22 +293,37 @@ export const AGENTS_MARKER = '<!-- decklight:skill -->';
152
293
  */
153
294
  export function agentsSection(referenceHref = '.claude/skills/decklight/reference.md') {
154
295
  return `${AGENTS_MARKER}
296
+ ${SKILL_STAMP()}
155
297
  ## Decklight decks
156
298
 
157
299
  This project contains a Decklight presentation (a single-file HTML deck —
158
300
  see \`${referenceHref}\` for the full authoring
159
- contract: builds, notes, SVG diagrams, themes, terminals, narration).
301
+ contract: builds, notes, sources, SVG diagrams, themes, terminals, narration).
160
302
  Read that file before adding or editing slides.
161
303
 
304
+ When slides come from material (PDFs, web pages, documents, files), give each
305
+ slide a \`<aside class="sources">\` as you write it, linking the part it uses
306
+ (PDF pages via \`#page=N\`, a page section via its anchor, file lines in the
307
+ note), cite only what you actually read, and end with a report to the user of
308
+ each source, the parts used, the slides citing it, and the slides with none.
309
+
162
310
  After editing slides, render the deck and check nothing is clipped:
163
311
  \`npx decklight@latest pdf deck.html -o /tmp/check.pdf\` — every \`⚠ slide N overflows\`
164
312
  line is a slide losing content. Overflow is the late failure, though: a slide
165
313
  that fits can still be too crowded, so keep to one idea and ~3–4 bullets per
166
314
  column rather than to whatever renders.
167
315
 
168
- When an authoring server is running (\`decklight author\`), commit each logical
316
+ On a deck with a design system, a slide fills a template's slots
317
+ (\`<section data-template="acme/section-divider">\` and children carrying
318
+ \`data-slot\`, listed by \`decklight design-system templates <ref>\`) and never
319
+ recreates its structure by hand; \`decklight check deck.html\` names any slot
320
+ or template the design system does not have. On a design system with roles,
321
+ every colour is a role (\`var(--acme-color-<role>)\`), never a swatch, a theme
322
+ token or a literal; \`check\` names each one that is not (\`off-role\`).
323
+
324
+ When the deck is open in write mode (\`decklight deck.html\`), commit each logical
169
325
  change you finish rather than leaving it to the timer's generic \`autosave\`:
170
- \`curl -sf -X POST localhost:8788/edit/commit -H 'content-type: application/json'
326
+ \`curl -sf -X POST localhost:8788/deck/edit/commit -H 'content-type: application/json'
171
327
  -d '{"message":"what this change did"}'\`. No server listening means no
172
328
  authoring session — skip it and carry on.
173
329
 
@@ -194,6 +350,7 @@ export function reportBugSkillMd() {
194
350
  name: decklight-report-bug
195
351
  description: File a Decklight bug report — gather version and environment facts, ask what broke and how to reproduce it, optionally attach a headless screenshot, and open the issue only after the user approves the full text. Use when the user hits a Decklight bug or asks to report one.
196
352
  ---
353
+ ${SKILL_STAMP()}
197
354
 
198
355
  Help the user file a bug report against Decklight that a triager can act on
199
356
  without a round trip. Work in this order.
package/cli/skills.mjs CHANGED
@@ -33,8 +33,9 @@ import { makeFail, runMain } from './util.mjs';
33
33
  import { isMain } from '../tools/args.mjs';
34
34
  import { zipSync } from './zip.mjs';
35
35
  import {
36
- PKG, AGENTS_MARKER, agentsSection, claudeSkillMd, referenceDoc, reportBugSkillMd,
36
+ PKG, AGENTS_MARKER, agentsSection, claudeSkillMd, referenceDoc, reportBugSkillMd, skillVersionOf,
37
37
  } from './skill-content.mjs';
38
+ import { semverCompare } from '../tools/semver.mjs';
38
39
 
39
40
  // The reference doc, relative to whatever dir carries it. Skills keep their
40
41
  // own copy next to SKILL.md; AGENTS.md agents keep one under .decklight/.
@@ -74,7 +75,7 @@ const HELP = `decklight skills — install the Decklight authoring skill for AI
74
75
 
75
76
  Usage:
76
77
  decklight skills [agent…] [--dir path | --global] [--all] [--force]
77
- decklight skills add|list|remove <name> marketplace skills
78
+ decklight library add skill|list|remove <name> marketplace skills
78
79
 
79
80
  Agents:
80
81
  ${Object.entries(TARGETS).map(([k, t]) => ` ${k.padEnd(9)} ${t.label}`).join('\n')}
@@ -102,7 +103,7 @@ and IBM Bob get a marked section in AGENTS.md. Both point at a reference
102
103
  sliced from this version's SPEC.md, so the contract never drifts from the
103
104
  installed runtime.
104
105
 
105
- Marketplace skills (decklight skills add <name>) are a different thing and
106
+ Marketplace skills (decklight library add skill <name>) are a different thing and
106
107
  live somewhere else — ~/.decklight/skills/ — so they sit ALONGSIDE the
107
108
  authoring skill above and never replace it. The command above always writes
108
109
  the authoring skill; nothing installed from a catalog changes that.
@@ -131,15 +132,37 @@ export function display(file) {
131
132
  return file;
132
133
  }
133
134
 
134
- /** Write a file, refusing to clobber an existing one without --force. */
135
- function writeIfAbsent(file, content, force) {
135
+ /**
136
+ * Is the skill text on disk older than the one this build would write?
137
+ * A file with no stamp predates the stamp (0.9.0) and counts as older.
138
+ */
139
+ function staleSkill(file, content) {
140
+ const mine = skillVersionOf(content);
141
+ if (!mine) return false;
142
+ let theirs = null;
143
+ try { theirs = skillVersionOf(fs.readFileSync(file, 'utf8')); } catch { return false; }
144
+ return theirs === null || (semverCompare(theirs, mine) ?? -1) < 0;
145
+ }
146
+
147
+ /**
148
+ * Write a file. An existing one is refreshed when it is OLDER than this build
149
+ * (the files are derived content, and an agent reading an old contract is
150
+ * the failure this exists to prevent) or when `refresh` says its sibling was;
151
+ * one that is already this version is left alone (null) without --force, and
152
+ * the command fails only when NOTHING needed writing — a current install
153
+ * asked for again, which is what --force is for.
154
+ */
155
+ function writeIfAbsent(file, content, force, { refresh = null } = {}) {
136
156
  if (fs.existsSync(file) && !force) {
137
- fail(`${display(file)} already exists — pass --force to overwrite`);
157
+ const stale = refresh ?? staleSkill(file, content);
158
+ if (!stale) return null;
138
159
  }
139
160
  fs.mkdirSync(path.dirname(file), { recursive: true });
140
161
  fs.writeFileSync(file, content);
141
162
  return file;
142
163
  }
164
+ /** `display` of a write, or nothing for a file left alone. */
165
+ const wrote = (file) => (file ? display(file) : null);
143
166
 
144
167
  /** Add/refresh the marked Decklight block in the AGENTS.md under `dir`. */
145
168
  function mergeAgentsMd(dir, refHref) {
@@ -162,8 +185,11 @@ function mergeAgentsMd(dir, refHref) {
162
185
 
163
186
  /** Write Claude's self-contained skill (SKILL.md + reference) into skillDir. */
164
187
  function installClaudeSkill(skillDir, force, written) {
165
- written.push(display(writeIfAbsent(path.join(skillDir, 'SKILL.md'), claudeSkillMd(SKILL_REF), force)));
166
- written.push(display(writeIfAbsent(path.join(skillDir, SKILL_REF), referenceDoc(), force)));
188
+ const skill = path.join(skillDir, 'SKILL.md');
189
+ // the reference carries no stamp of its own: it follows the SKILL.md beside it
190
+ const refresh = fs.existsSync(skill) ? staleSkill(skill, claudeSkillMd(SKILL_REF)) : null;
191
+ written.push(wrote(writeIfAbsent(skill, claudeSkillMd(SKILL_REF), force)));
192
+ written.push(wrote(writeIfAbsent(path.join(skillDir, SKILL_REF), referenceDoc(), force, { refresh })));
167
193
  }
168
194
 
169
195
  /**
@@ -173,7 +199,7 @@ function installClaudeSkill(skillDir, force, written) {
173
199
  */
174
200
  function installReportBugSkill(skillsRoot, force, written) {
175
201
  const dir = path.join(skillsRoot, 'decklight-report-bug');
176
- written.push(display(writeIfAbsent(path.join(dir, 'SKILL.md'), reportBugSkillMd(), force)));
202
+ written.push(wrote(writeIfAbsent(path.join(dir, 'SKILL.md'), reportBugSkillMd(), force)));
177
203
  }
178
204
 
179
205
  // --- project scope: one repo, one shared AGENTS.md for every agent ----------
@@ -195,10 +221,10 @@ function installProject(targets, dir, force) {
195
221
  // one reference copy: Claude's skill dir when Claude is also a target,
196
222
  // else a standalone .decklight/ copy the AGENTS.md agents point at.
197
223
  const refHref = wantsClaude ? CLAUDE_REF : SHARED_REF;
198
- if (!wantsClaude) written.push(display(writeIfAbsent(path.join(root, SHARED_REF), referenceDoc(), force)));
224
+ if (!wantsClaude) written.push(wrote(writeIfAbsent(path.join(root, SHARED_REF), referenceDoc(), force)));
199
225
  written.push(mergeAgentsMd(root, refHref));
200
226
  }
201
- return written;
227
+ return written.filter(Boolean);
202
228
  }
203
229
 
204
230
  // --- global scope: each agent self-contained in its own config home ---------
@@ -212,11 +238,68 @@ function installGlobal(targets, env, force) {
212
238
  installClaudeSkill(path.join(home, 'skills', 'decklight'), force, written);
213
239
  installReportBugSkill(path.join(home, 'skills'), force, written);
214
240
  } else {
215
- written.push(display(writeIfAbsent(path.join(home, SHARED_REF), referenceDoc(), force)));
241
+ written.push(wrote(writeIfAbsent(path.join(home, SHARED_REF), referenceDoc(), force)));
216
242
  written.push(mergeAgentsMd(home, SHARED_REF));
217
243
  }
218
244
  }
219
- return written;
245
+ return written.filter(Boolean);
246
+ }
247
+
248
+ // --- what is on this machine, against this build ------------------------------
249
+
250
+ /**
251
+ * The skill files older than this install, where `decklight <deck>` looks
252
+ * before it serves (PRESENTING): the project's, under `dir` (Claude's
253
+ * `.claude/skills/decklight/SKILL.md`, and an AGENTS.md carrying the marked
254
+ * section), and every agent's global home, whether or not that agent is on
255
+ * PATH today: a file that was installed is a file something reads. A stamp
256
+ * older than this build, or missing (before 0.9.0), is stale. Each entry is
257
+ * `{ scope: 'project' | 'global', target, file, version }`.
258
+ */
259
+ export function staleSkills({ dir = '.', env = process.env } = {}) {
260
+ const out = [];
261
+ const look = (scope, target, file, kind) => {
262
+ if (!fs.existsSync(file)) return;
263
+ let text = '';
264
+ try { text = fs.readFileSync(file, 'utf8'); } catch { return; }
265
+ if (kind === 'agents' && !text.includes(AGENTS_MARKER)) return;
266
+ const version = skillVersionOf(text);
267
+ if (version === null || (semverCompare(version, PKG.version) ?? -1) < 0) out.push({ scope, target, file, version });
268
+ };
269
+ const root = path.resolve(dir);
270
+ look('project', 'claude', path.join(root, '.claude', 'skills', 'decklight', 'SKILL.md'), 'skill');
271
+ look('project', 'agents', path.join(root, 'AGENTS.md'), 'agents');
272
+ for (const [key, t] of Object.entries(TARGETS)) {
273
+ const home = t.home(env);
274
+ if (t.kind === 'skill') look('global', key, path.join(home, 'skills', 'decklight', 'SKILL.md'), 'skill');
275
+ else look('global', key, path.join(home, 'AGENTS.md'), 'agents');
276
+ }
277
+ return out;
278
+ }
279
+
280
+ /**
281
+ * Bring the files `staleSkills` named up to this build, and nothing else: a
282
+ * project whose AGENTS.md is stale gets its section refreshed, not a Claude
283
+ * skill it never had. The same writers as `decklight skills`, so a refresh
284
+ * from the prompt and one from the command cannot differ. Returns the lines
285
+ * the command would print, one per file written.
286
+ */
287
+ export function refreshSkills(stale, { dir = '.', env = process.env } = {}) {
288
+ const written = [];
289
+ const root = path.resolve(dir);
290
+ const project = stale.filter((s) => s.scope === 'project');
291
+ if (project.some((s) => s.target === 'claude')) {
292
+ installClaudeSkill(path.join(root, '.claude', 'skills', 'decklight'), false, written);
293
+ installReportBugSkill(path.join(root, '.claude', 'skills'), false, written);
294
+ }
295
+ if (project.some((s) => s.target === 'agents')) {
296
+ const hasClaude = fs.existsSync(path.join(root, CLAUDE_REF));
297
+ if (!hasClaude) written.push(wrote(writeIfAbsent(path.join(root, SHARED_REF), referenceDoc(), false)));
298
+ written.push(mergeAgentsMd(root, hasClaude ? CLAUDE_REF : SHARED_REF));
299
+ }
300
+ const globals = [...new Set(stale.filter((s) => s.scope === 'global').map((s) => s.target))];
301
+ if (globals.length) written.push(...installGlobal(Object.keys(TARGETS).filter((k) => globals.includes(k)), env, false));
302
+ return written.filter(Boolean);
220
303
  }
221
304
 
222
305
  /**
@@ -251,22 +334,17 @@ export function packSkill() {
251
334
  }
252
335
 
253
336
  /**
254
- * `add`, `list` and `remove` are marketplace skills (`UNITS#REST`); every
255
- * other positional is an agent name. They share this command because they
256
- * are the same subject — a skill — and a separate `decklight skill` beside
257
- * `decklight skills` would be a footgun that reads as a typo either way.
258
- *
259
- * Unambiguous in practice: the agent roster is a closed set of nouns
260
- * (`claude`, `codex`, …) and these are verbs, so no name can be both. A
261
- * future agent called "list" would collide, and the roster is ours.
337
+ * `add`, `list` and `remove` were marketplace skills (`UNITS#REST`) and lived
338
+ * here; they are `decklight library <verb> skill` now, with every other kind
339
+ * of unit. Said by name rather than read as an agent called "add": the
340
+ * roster is a closed set of nouns and these are verbs.
262
341
  */
263
342
  const UNIT_SUBCOMMANDS = new Set(['add', 'list', 'remove']);
264
343
 
265
344
  export async function skillsMain(argv = process.argv.slice(2), { hasBin = onPath, env = process.env } = {}) {
266
345
  if (UNIT_SUBCOMMANDS.has(argv[0])) {
267
- const { unitMain } = await import('./units.mjs');
268
- const code = await unitMain('skill', argv);
269
- if (code) process.exitCode = code;
346
+ console.error(`decklight skills ${argv[0]}: marketplace skills are in your library — decklight library ${argv[0]} skill ${argv.slice(1).join(' ')}`.trimEnd());
347
+ process.exitCode = 1;
270
348
  return;
271
349
  }
272
350
  if (argv.includes('--help') || argv.includes('-h')) {
@@ -327,6 +405,11 @@ export async function skillsMain(argv = process.argv.slice(2), { hasBin = onPath
327
405
  const targets = Object.keys(TARGETS).filter((k) => selected.includes(k));
328
406
 
329
407
  const written = global ? installGlobal(targets, env, force) : installProject(targets, dir ?? '.', force);
408
+ // Every file was already this version: nothing to do, said as a refusal so a
409
+ // script that expected a write learns it did not happen — --force rewrites.
410
+ if (!written.some((w) => !/^refreshed the Decklight section/.test(w) || force)) {
411
+ fail(`the Decklight skill is already this version (${PKG.version}) — pass --force to overwrite`);
412
+ }
330
413
 
331
414
  const where = global ? 'globally' : `in ${display(path.resolve(dir ?? '.'))}`;
332
415
  process.stdout.write(
package/cli/start.mjs ADDED
@@ -0,0 +1,110 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * A bare `decklight`, on a terminal.
6
+ *
7
+ * It used to print forty commands. The person who types nothing but the
8
+ * program's name is asking "what now?", and the answer depends on where they
9
+ * are standing: a directory with no deck wants one started, a directory with
10
+ * one deck wants it opened, a directory with several wants a choice. Each is
11
+ * a question with a default, and every answer lands in a command that already
12
+ * exists — this file starts nothing of its own.
13
+ *
14
+ * Off a terminal there is nobody to ask, and the dispatcher prints the short
15
+ * help instead of ever reaching this.
16
+ */
17
+
18
+ import { createInterface } from 'node:readline/promises';
19
+ import { findDeck } from './history.mjs';
20
+ import { shortHelp } from './commands.mjs';
21
+
22
+ /** What a bare `decklight` should do here — pure over what the directory holds. */
23
+ export function planStart({ decks = [], tty = false } = {}) {
24
+ if (!tty) return { action: 'help' };
25
+ if (!decks.length) return { action: 'offer-init' };
26
+ if (decks.length === 1) return { action: 'offer-open', deck: decks[0] };
27
+ return { action: 'choose', decks };
28
+ }
29
+
30
+ /**
31
+ * Which way in an `[Enter/n/q]` answer picks. Enter is write mode — the deck
32
+ * in front of you is far more often one you are working on than one you were
33
+ * sent; `n` opens it without trust.
34
+ */
35
+ export function pickVerb(answer) {
36
+ const a = String(answer ?? '').trim().toLowerCase();
37
+ if (!a || a.startsWith('e') || a.startsWith('w') || a.startsWith('o')) return 'write';
38
+ if (a.startsWith('n')) return 'no-trust';
39
+ return null;
40
+ }
41
+
42
+ /** Which of `decks` a numbered answer names; Enter is the first, nonsense is null. */
43
+ export function pickDeck(answer, decks) {
44
+ const a = String(answer ?? '').trim();
45
+ if (!a) return decks[0] ?? null;
46
+ const n = Number(a);
47
+ if (Number.isInteger(n) && n >= 1 && n <= decks.length) return decks[n - 1];
48
+ return decks.find((d) => d === a || d.toLowerCase() === a.toLowerCase()) ?? null;
49
+ }
50
+
51
+ export async function startMain(argv = [], {
52
+ cwd = process.cwd(),
53
+ tty = Boolean(process.stdin.isTTY && process.stdout.isTTY),
54
+ out = process.stdout,
55
+ ask = null,
56
+ run = {},
57
+ } = {}) {
58
+ if (argv.includes('--help') || argv.includes('-h')) {
59
+ out.write(shortHelp());
60
+ return 0;
61
+ }
62
+ const plan = planStart({ decks: findDeck(cwd).decks, tty });
63
+ if (plan.action === 'help') { out.write(shortHelp()); return 0; }
64
+
65
+ // one readline for every question; EOF anywhere is "no", never a hang
66
+ const rl = ask ? null : createInterface({ input: process.stdin, output: process.stdout });
67
+ let gone = false;
68
+ rl?.once('close', () => { gone = true; });
69
+ const question = async (q) => {
70
+ if (ask) return String(await ask(q) ?? '');
71
+ if (gone) return null;
72
+ return new Promise((res) => {
73
+ rl.once('close', () => res(null));
74
+ rl.question(q).then(res, () => res(null));
75
+ });
76
+ };
77
+ const yes = (a, dflt = true) => (a === null ? false : !a.trim() ? dflt : /^y/i.test(a.trim()));
78
+ const launch = {
79
+ init: run.init ?? (async (args) => (await import('./init.mjs')).initMain(args)),
80
+ write: run.write ?? (async (args) => (await import('./open.mjs')).openMain(args)),
81
+ 'no-trust': run['no-trust'] ?? (async (args) => (await import('./open.mjs')).openMain(args)),
82
+ };
83
+
84
+ try {
85
+ if (plan.action === 'offer-init') {
86
+ const a = await question('no decklight deck in this directory — start one here? [Y/n] ');
87
+ if (!yes(a)) { out.write(`\n${shortHelp()}`); return 0; }
88
+ rl?.close();
89
+ return (await launch.init([])) ?? 0;
90
+ }
91
+
92
+ let deck = plan.deck;
93
+ if (plan.action === 'choose') {
94
+ out.write(`${plan.decks.length} decks here:\n`);
95
+ plan.decks.forEach((d, i) => out.write(` ${i + 1}) ${d}\n`));
96
+ const a = await question(`which one? [1] `);
97
+ deck = a === null ? null : pickDeck(a, plan.decks);
98
+ if (!deck) { out.write('nothing opened\n'); return 0; }
99
+ } else {
100
+ out.write(`found ${deck}\n`);
101
+ }
102
+ const a = await question(' open it — live reload, edits from the browser, an AI agent on A n) without trust — its code stripped, nothing changes it\n [Enter/n/q] ');
103
+ const verb = a === null ? null : pickVerb(a);
104
+ if (!verb) { out.write('nothing opened\n'); return 0; }
105
+ rl?.close();
106
+ return (await launch[verb](verb === 'write' ? [deck, '--open'] : [deck, '--no-trust'])) ?? 0;
107
+ } finally {
108
+ rl?.close();
109
+ }
110
+ }