decklight 0.8.1 → 0.10.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 (138) hide show
  1. package/PLATFORM.md +707 -0
  2. package/README.md +226 -150
  3. package/SPEC.md +803 -888
  4. package/cli/agent-review.mjs +246 -0
  5. package/cli/agents.mjs +35 -9
  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 +190 -0
  10. package/cli/bundle-module.mjs +95 -0
  11. package/cli/bundle.mjs +439 -35
  12. package/cli/cast.mjs +48 -12
  13. package/cli/check-fixes.mjs +186 -0
  14. package/cli/check.mjs +988 -0
  15. package/cli/clone-deck.mjs +179 -0
  16. package/cli/commands.mjs +345 -0
  17. package/cli/comments.mjs +64 -18
  18. package/cli/commit-flow.mjs +51 -22
  19. package/cli/commit-message.mjs +51 -74
  20. package/cli/commit-split.mjs +601 -0
  21. package/cli/deck-refs.mjs +64 -0
  22. package/cli/deck-routes.mjs +67 -0
  23. package/cli/deckfile.mjs +3 -5
  24. package/cli/decklight.mjs +68 -289
  25. package/cli/design-system-deps.mjs +209 -0
  26. package/cli/design-system-edit.mjs +194 -0
  27. package/cli/design-system-refs.mjs +666 -0
  28. package/cli/design-system.mjs +497 -0
  29. package/cli/doctor.mjs +115 -0
  30. package/cli/edit-git.mjs +353 -0
  31. package/cli/edit-handover.mjs +551 -0
  32. package/cli/edit-look.mjs +631 -0
  33. package/cli/edit-slides.mjs +683 -0
  34. package/cli/edit.mjs +2585 -855
  35. package/cli/enhance.mjs +485 -0
  36. package/cli/extension.mjs +10 -10
  37. package/cli/font-refs.mjs +273 -0
  38. package/cli/font.mjs +246 -0
  39. package/cli/git-tree.mjs +1 -1
  40. package/cli/git.mjs +78 -11
  41. package/cli/import.mjs +56 -10
  42. package/cli/init.mjs +407 -236
  43. package/cli/library.mjs +127 -0
  44. package/cli/loader.mjs +3 -1
  45. package/cli/marketplace-autocheck.mjs +200 -0
  46. package/cli/marketplace.mjs +460 -29
  47. package/cli/narrate.mjs +251 -0
  48. package/cli/open-browser.mjs +63 -0
  49. package/cli/open.mjs +961 -0
  50. package/cli/pdf.mjs +64 -17
  51. package/cli/pkg.mjs +44 -2
  52. package/cli/plugin.mjs +43 -41
  53. package/cli/port-conflict.mjs +53 -23
  54. package/cli/pptx-export.mjs +63 -27
  55. package/cli/publish.mjs +8 -4
  56. package/cli/qr.mjs +1 -1
  57. package/cli/record.mjs +85 -23
  58. package/cli/remote.mjs +43 -17
  59. package/cli/restore.mjs +11 -4
  60. package/cli/review-ref.mjs +125 -0
  61. package/cli/review-remote.mjs +92 -48
  62. package/cli/review-routes.mjs +254 -0
  63. package/cli/review-store.mjs +47 -7
  64. package/cli/review-submit.mjs +47 -57
  65. package/cli/runtime-link.mjs +560 -0
  66. package/cli/serve.mjs +236 -45
  67. package/cli/setup.mjs +112 -0
  68. package/cli/sign.mjs +1 -1
  69. package/cli/skill-content.mjs +229 -35
  70. package/cli/skills.mjs +353 -26
  71. package/cli/start.mjs +110 -0
  72. package/cli/supervise.mjs +6 -6
  73. package/cli/theme-refs.mjs +527 -0
  74. package/cli/theme.mjs +181 -137
  75. package/cli/trust.mjs +83 -0
  76. package/cli/units.mjs +112 -47
  77. package/cli/update-check.mjs +1 -5
  78. package/cli/upgrade.mjs +194 -28
  79. package/cli/upstream.mjs +4 -3
  80. package/cli/util.mjs +4 -4
  81. package/cli/wizard.mjs +6 -6
  82. package/dist/build-info.json +1 -1
  83. package/dist/decklight.css +1533 -59
  84. package/dist/decklight.js +258 -115
  85. package/dist/decklight.js.map +4 -4
  86. package/docs/GLOSSARY.md +141 -0
  87. package/docs/architecture.svg +17 -17
  88. package/package.json +4 -2
  89. package/themes/README.md +9 -8
  90. package/themes/reveal-solarized.css +10 -0
  91. package/tools/args.mjs +20 -0
  92. package/tools/atomic-write.mjs +48 -0
  93. package/tools/brand-palette.mjs +717 -0
  94. package/tools/bridge.mjs +1 -1
  95. package/tools/build-groups.mjs +42 -0
  96. package/tools/color.mjs +48 -0
  97. package/tools/deck-html.mjs +396 -11
  98. package/tools/design-system-format.mjs +778 -0
  99. package/tools/design-system-migrations.mjs +207 -0
  100. package/tools/elevenlabs-tts.mjs +110 -17
  101. package/tools/exec.mjs +11 -3
  102. package/tools/extension-check.mjs +31 -7
  103. package/tools/font-format.mjs +190 -0
  104. package/tools/font-stacks.mjs +24 -0
  105. package/tools/gemini-tts.mjs +3 -0
  106. package/tools/lipsync-config.mjs +103 -0
  107. package/tools/lipsync-engines.mjs +205 -2
  108. package/tools/lipsync-server.mjs +264 -41
  109. package/tools/lipsync.mjs +37 -18
  110. package/tools/local-voice.mjs +32 -42
  111. package/tools/narration-manifest.mjs +270 -0
  112. package/tools/narration-synth.mjs +416 -0
  113. package/tools/pptx.mjs +776 -19
  114. package/tools/publish-targets.mjs +1 -1
  115. package/tools/publish-voices.mjs +3 -3
  116. package/tools/recording-impact.mjs +7 -3
  117. package/tools/render-theme.mjs +33 -0
  118. package/tools/review-anchor.mjs +28 -12
  119. package/tools/semver.mjs +40 -0
  120. package/tools/sentences.mjs +180 -0
  121. package/tools/shot.mjs +14 -7
  122. package/tools/site-clip.mjs +114 -0
  123. package/tools/site-voices.mjs +232 -0
  124. package/tools/template-theme.mjs +1 -1
  125. package/tools/test-impact.mjs +17 -10
  126. package/tools/theme-check.mjs +30 -3
  127. package/tools/tts-cache.mjs +4 -3
  128. package/tools/tts-engines.mjs +38 -20
  129. package/tools/tts-setup.mjs +7 -7
  130. package/tools/video-options.mjs +34 -0
  131. package/tools/video.mjs +530 -54
  132. package/tools/voiceover-server.mjs +185 -104
  133. package/tools/voiceover.mjs +119 -261
  134. package/tools/zip.mjs +1 -1
  135. package/cli/dev.mjs +0 -623
  136. package/cli/present.mjs +0 -853
  137. package/cli/review.mjs +0 -361
  138. package/tools/publish-site-voices.mjs +0 -75
package/cli/init.mjs CHANGED
@@ -7,77 +7,78 @@
7
7
  * Code (and any AGENTS.md-reading agent) knows the authoring contract
8
8
  * without a web search or a guess from Reveal.js memory.
9
9
  *
10
- * decklight init ["My Deck"] [-o deck.html] [--dir path] [--themes …]
11
- * [--from <template>] [--git | --no-git] [--open] [--force]
12
- * [--no-skill | --global-skill]
10
+ * decklight init ["My Deck"] [-o deck.html] [--dir path] [--inline [--themes …]]
11
+ * [--design-system <ref> | --no-design-system]
12
+ * [--git | --no-git] [--remote <url> | --no-remote]
13
+ * [--no-open] [--force] [--no-skill | --global-skill]
13
14
  *
14
- * Run bare in a terminal it asks one question — the deck's title — with
15
- * "My Deck" as the default; a title argument (or a non-TTY run) never prompts.
16
- * A terminal run is also asked where the skill should live: the project
17
- * (today's install, the default) or globally in each PATH-detected agent's
18
- * config home — the same files `decklight skills --global` installs.
19
- * --global-skill preselects global, --no-skill skips skill and question,
20
- * and a non-TTY run keeps the project install without asking.
15
+ * A terminal run can ask up to five questions, each skipped by its flag or
16
+ * by a non-TTY run: the deck's title ("My Deck" by default), which design
17
+ * system it is built on (only when a cached catalog offers one), where the
18
+ * skill goes (the project, or each detected agent's config home), whether to
19
+ * create a git repository, and, for a repository it just created, a remote.
21
20
  *
22
- * The deck is fully self-contained (runtime + every theme inlined, like
23
- * `decklight bundle --themes all` produces) — double-click it, it presents,
24
- * no sibling files, and the in-deck picker is fully stocked. Pass --themes to
25
- * ship a narrower set. The runtime blocks are marked data-decklight-runtime
26
- * so `decklight upgrade` can swap them for a newer installed version later.
27
- * The skill is regenerated every run (it's derived, not
28
- * authored content) so re-running after an upgrade refreshes it; the deck
29
- * file is only touched with --force.
21
+ * The deck is data by default: slides plus a JSON configuration block, with
22
+ * no runtime in the file. `decklight <deck>` serves the installed runtime into
23
+ * it, and `decklight bundle` embeds it when the deck is handed over.
24
+ * `--inline` writes the self-contained shape instead, with the runtime and
25
+ * the themes `--themes` selects. The skill is regenerated every run (it is
26
+ * derived, not authored content), so re-running after an upgrade refreshes
27
+ * it; the deck file is only touched with --force.
30
28
  *
31
- * init ends like the start of an authoring session: outside a repository it
32
- * offers `git init` (the same question `decklight author` asks, at the natural
33
- * moment — the repo starts with the shared starter .gitignore), prints an
34
- * accent-colored epilogue — the deck's file:// URL and the `decklight author`
35
- * line, which is the command that starts editing. `--open` launches the deck
36
- * in the default browser (the file IS the presentation).
29
+ * On a terminal, init ends by opening the deck in write mode. Off a terminal
30
+ * it prints the command and starts nothing.
37
31
  */
38
32
 
39
33
  import fs from 'node:fs';
40
34
  import path from 'node:path';
41
35
  const { basename, relative } = path;
42
- import { pathToFileURL } from 'node:url';
43
- import { spawn, execFileSync } from 'node:child_process';
36
+ import { fileURLToPath, pathToFileURL } from 'node:url';
37
+ import { execFileSync, spawnSync } from 'node:child_process';
44
38
  import { createInterface } from 'node:readline/promises';
45
39
 
46
40
  import {
47
41
  PKG, PKG_ROOT, AGENTS_MARKER, agentsSection, claudeSkillMd, referenceDoc,
48
42
  } from './skill-content.mjs';
49
43
  import { THEMES_DIR, themeCss, runtimeCss, runtimeJs } from './pkg.mjs';
50
- import { TARGETS, detectedTargets, installGlobalSkill, display } from './skills.mjs';
51
- import { onPath, detectAgents } from './agents.mjs';
52
- import {
53
- ASK_MESSAGES, planCommitMessages, rememberPref, storedPref,
54
- } from './commit-message.mjs';
44
+ import { configBlock, configBlockHtml, configVersion, hasRuntime } from './runtime-link.mjs';
45
+ import { TARGETS, detectedTargets, installGlobalSkill, display, syncLibrarySkills } from './skills.mjs';
46
+ import { librarySkills } from './units.mjs';
47
+ import { onPath } from './agents.mjs';
55
48
  import { escapeHtml } from './edit.mjs';
56
49
  import {
57
50
  classifyRemoteError, createRepo, foreignWarning, git as gitRun, inGitRepo, isIdentityError,
58
51
  looksLikeGitUrl, noPromptEnv, oneline, remoteNames, splitDeckPaths,
59
52
  } from './git.mjs';
60
53
  import { makeFail, runMain } from './util.mjs';
54
+ import { configHome } from './marketplace.mjs';
55
+ import { openCommand, openDeck, openUrl } from './open-browser.mjs';
56
+
57
+ // still exported from here — record and review used to import the opener from init
58
+ export { openCommand, openDeck, openUrl };
61
59
  import { isMain } from '../tools/args.mjs';
62
60
 
63
61
  const fail = makeFail('init');
64
62
 
65
63
  /**
66
- * Is this HTML a decklight deck, and which runtime does it carry?
67
- * Keys on the markers init itself writes — the `class="decklight"` stage div
68
- * plus the `Decklight.init(` call — and reads the version from the bundle's
64
+ * Is this HTML a decklight deck, and which runtime was it written for?
65
+ * Keys on the `class="decklight"` stage div plus one of the three things a
66
+ * deck boots by: a `Decklight.init(` call, a configuration block (#520), or a
67
+ * runtime in the file. The version comes from the bundle's
69
68
  * `/*! Decklight vX.Y.Z … ` banner (stamped by build.mjs; minification makes
70
- * the exported const unfindable).
69
+ * the exported const unfindable), a linked deck's `data-decklight-version`
70
+ * (#517), or the block's `decklight` key.
71
71
  *
72
72
  * @returns the runtime version string; `null` for a decklight deck whose
73
73
  * version can't be extracted; `undefined` for a non-deck.
74
74
  */
75
75
  export function deckRuntimeVersion(html) {
76
76
  const isDeck = /<[a-z][^>]*\bclass=["'](?:[^"']*\s)?decklight(?:\s[^"']*)?["']/i.test(html)
77
- && /Decklight\.init\s*\(/.test(html);
77
+ && (/Decklight\.init\s*\(/.test(html) || !!configBlock(html) || hasRuntime(html));
78
78
  if (!isDeck) return undefined;
79
- const banner = /\/\*!\s*Decklight v(\d+\.\d+\.\d+[^\s*]*)/.exec(html);
80
- return banner ? banner[1] : null;
79
+ const banner = /\/\*!\s*Decklight v(\d+\.\d+\.\d+[^\s*]*)/.exec(html)
80
+ ?? /<script\b[^>]*\bsrc=["'][^"']*decklight[^"']*\.js["'][^>]*\bdata-decklight-version=["']([^"']+)["']/i.exec(html);
81
+ return banner ? banner[1] : configVersion(html);
81
82
  }
82
83
 
83
84
  // aurora is the deck's starting look; init ships every theme by default so the
@@ -102,60 +103,6 @@ function resolveThemes(sel) {
102
103
  return names;
103
104
  }
104
105
 
105
- /**
106
- * The deck body for `--from <template>`: an installed template, or a refusal
107
- * that names how to install one (`UNITS#REST`).
108
- *
109
- * It **refuses rather than fetching**, and that is the point of the flag's
110
- * design. `init` scaffolds; installing is a separate, explicit act, exactly as
111
- * it is for `theme add` and `plugin add`. The alternative — resolve the name
112
- * in a catalog and download it right here — would make the one command people
113
- * run first into a command that reaches the network, and would do it on the
114
- * machine least likely to have been asked. So an uninstalled name is met with
115
- * the install line, and a name nothing offers is met with that instead.
116
- *
117
- * The lookup is cache-only, so this stays as offline as `init` has always been.
118
- */
119
- export function templateDeck(name, { home, listInstalled, offered } = {}) {
120
- const found = listInstalled(name, home);
121
- if (found) return { ok: true, html: fs.readFileSync(found.path, 'utf8') };
122
-
123
- // Returns the refusal rather than exiting, the way planGit and planSkill
124
- // return a decision — the caller acts. A helper that ends the process is a
125
- // helper that can only be tested by starting one.
126
- const any = offered(home);
127
- const candidate = any.find((e) => e.name === name);
128
- if (candidate) {
129
- return { ok: false, message: `no template "${name}" installed — a registered marketplace offers it:\n`
130
- + ` decklight template add ${candidate.qualified}\n`
131
- + ' then run this again. Installing is its own step on purpose: init does not\n'
132
- + ' reach the network, and a scaffold command should not start now.' };
133
- }
134
- return { ok: false, message: `no template "${name}" installed, and no registered marketplace offers one`
135
- + (any.length ? `\n available: ${any.map((e) => e.qualified).join(', ')}` : '')
136
- + '\n decklight template list — what is installed and what is offered'
137
- + '\n decklight marketplace add <owner/repo> — register a catalog to install from' };
138
- }
139
-
140
- /**
141
- * Put the title into a template's `<title>` and first `<h1>`, and nothing else.
142
- *
143
- * A template is someone's deck, so this is deliberately the smallest possible
144
- * edit: two substitutions that are true of every deck, rather than a
145
- * templating language that would make a template a program. Neither is
146
- * required — a template that wants its own title keeps it by not having an
147
- * `<h1>`, and the deck still scaffolds.
148
- */
149
- export function titleTemplate(html, title) {
150
- const safe = escapeHtml(title);
151
- // A function replacement, not a string one: a title is user input and may
152
- // contain `$&` or `$1`, which a string replacement would expand into the
153
- // matched text instead of printing.
154
- const put = (_m, open, _inner, close) => open + safe + close;
155
- return html
156
- .replace(/(<title>)([\s\S]*?)(<\/title>)/i, put)
157
- .replace(/(<h1[^>]*>)([\s\S]*?)(<\/h1>)/i, put);
158
- }
159
106
 
160
107
  // No title argument: ask on a TTY (the one thing every run would have passed
161
108
  // had the author known), scaffold the default silently everywhere else.
@@ -167,7 +114,7 @@ export async function resolveTitle(arg, { isTTY = false, ask } = {}) {
167
114
  }
168
115
 
169
116
  // ── git: offer the repository at the natural moment ─────────────────────────
170
- // The same policy `decklight author` applies later, decided here as a pure
117
+ // The same policy `decklight <deck>` applies later, decided here as a pure
171
118
  // function so the table (--git / --no-git / TTY / repo-present) is testable
172
119
  // without a repository or a terminal.
173
120
  export function planGit({ args = [], tty = false, inRepo = false } = {}) {
@@ -177,6 +124,19 @@ export function planGit({ args = [], tty = false, inRepo = false } = {}) {
177
124
  return { action: tty ? 'ask' : 'hint' };
178
125
  }
179
126
 
127
+ /**
128
+ * The arguments init hands to `decklight <deck>` once the deck is written.
129
+ *
130
+ * The git answer travels with them. Without it, a "no" to init's git question
131
+ * left the directory without a repository, and the deck it opened found none
132
+ * and asked the same question again a second later. `--no-git` typed to init
133
+ * travels too: "never touch git" is the person's, not one command's.
134
+ */
135
+ export function handoffArgs({ rel, argv = [], gitPlan, gitAction, noOpen = false }) {
136
+ const declined = argv.includes('--no-git') || (gitPlan === 'ask' && gitAction === 'skip');
137
+ return [rel, ...(declined ? ['--no-git'] : []), ...(noOpen ? [] : ['--open'])];
138
+ }
139
+
180
140
  /** Everything committed here that is not the deck — what a push would carry. */
181
141
  export function notTheDeck(root, deckPath, run = gitRun) {
182
142
  try {
@@ -294,6 +254,173 @@ export function planRemote({
294
254
  return { action: ghReady ? 'ask-gh' : 'ask-url', defaultYes: foreign === 0 };
295
255
  }
296
256
 
257
+ // ── the design system: a brand's deck starts on the brand ───────────────────
258
+ // Asked right after the title, and only when a CACHED catalog of a registered
259
+ // marketplace lists a design system this machine can resolve: nothing is
260
+ // fetched, so the question works on a plane and never slows init down. With
261
+ // none on offer there is no question and no new output. A pure table, like
262
+ // planGit: the rows are handed in, so it is testable without a marketplace.
263
+ export function planDesignSystem({ args = [], tty = false, inline = false, systems = [], unfetched = [], stale = [] } = {}) {
264
+ const i = args.indexOf('--design-system');
265
+ const ref = i >= 0 ? args[i + 1] : null;
266
+ const off = args.includes('--no-design-system');
267
+ if (i >= 0 && off) return { action: 'refuse', why: '--design-system and --no-design-system are mutually exclusive' };
268
+ if (i >= 0 && (!ref || ref.startsWith('-'))) return { action: 'refuse', why: '--design-system needs a design system (name or name@marketplace)' };
269
+ if (i >= 0 && inline) {
270
+ return { action: 'refuse', why: '--design-system cannot start an --inline deck: a self-contained file opened from disk has'
271
+ + ' no server to link a design system by reference (decklight bundle embeds one when the deck is handed over)' };
272
+ }
273
+ if (off) return { action: 'skip' };
274
+ if (ref) return { action: 'use', ref };
275
+ if (inline || !systems.length) return { action: 'skip' };
276
+ if (!tty) return { action: 'hint', systems };
277
+ return { action: 'ask', rows: systems, defaultIndex: systems.length === 1 ? 0 : null, unfetched, stale };
278
+ }
279
+
280
+ /**
281
+ * The question as printed: one row per design system (title, reference,
282
+ * version, and its description as a dim second line), `none` last, the
283
+ * marketplaces the cache cannot answer for as dim lines under it, and the
284
+ * prompt: `[1]:` when the one design system is the default, else the range.
285
+ */
286
+ export function designSystemQuestion(plan, { color = false } = {}) {
287
+ const dim = (s) => (color ? `${DIM}${s}${RESET}` : s);
288
+ const lines = ['design system for this deck?'];
289
+ plan.rows.forEach((r, n) => {
290
+ lines.push(` ${n + 1} ${r.title} — ${r.qualified}${r.version ? ` ${r.version}` : ''}`);
291
+ if (r.description) lines.push(dim(` ${r.description}`));
292
+ });
293
+ lines.push(` ${plan.rows.length + 1} none — decklight's own themes`);
294
+ for (const m of plan.unfetched ?? []) lines.push(dim(` ${m} has not been fetched yet — decklight marketplace update ${m}`));
295
+ for (const m of plan.stale ?? []) lines.push(dim(` ${m}'s cached catalog could not be read — decklight marketplace update ${m}`));
296
+ const prompt = plan.defaultIndex != null ? `[${plan.defaultIndex + 1}]: ` : `[1-${plan.rows.length + 1}]: `;
297
+ return { lines, prompt };
298
+ }
299
+
300
+ /**
301
+ * One answer to the question: `{ pick }` (a row, or null for none) or
302
+ * `{ again: true }`. Enter takes the default, and with no default asks again;
303
+ * a number, a name or `none` picks; anything else asks again. EOF picks none,
304
+ * as every init question degrades.
305
+ */
306
+ export function pickDesignSystem(answer, plan, { eof = false } = {}) {
307
+ const a = String(answer ?? '').trim();
308
+ if (!a) {
309
+ if (eof) return { pick: null };
310
+ return plan.defaultIndex != null ? { pick: plan.rows[plan.defaultIndex] } : { again: true };
311
+ }
312
+ if (/^\d+$/.test(a)) {
313
+ const n = Number(a);
314
+ if (n >= 1 && n <= plan.rows.length) return { pick: plan.rows[n - 1] };
315
+ if (n === plan.rows.length + 1) return { pick: null };
316
+ return { again: true };
317
+ }
318
+ if (/^none$/i.test(a)) return { pick: null };
319
+ const hits = plan.rows.filter((r) => r.qualified === a || r.name === a);
320
+ return hits.length === 1 ? { pick: hits[0] } : { again: true };
321
+ }
322
+
323
+ /** The one line a non-terminal run prints when a design system was on offer. */
324
+ export function designSystemHint(systems) {
325
+ return ` design system: none — this machine's marketplaces offer ${systems.map((s) => s.qualified).join(', ')};`
326
+ + ' --design-system <name@marketplace> starts a deck on one';
327
+ }
328
+
329
+ /**
330
+ * What the cached catalogs offer, as rows: every design-system entry this
331
+ * machine can resolve (one that needs a newer decklight, or whose checkout is
332
+ * gone, is left out), and the marketplaces the cache cannot answer for. Cache
333
+ * and checkouts only, never the network. A registry that does not read is
334
+ * nothing on offer: init is not the place to fail over it.
335
+ */
336
+ export async function availableDesignSystems(home = configHome()) {
337
+ try {
338
+ const { marketplaceDesignSystems, resolveDesignSystemRef } = await import('./design-system-refs.mjs');
339
+ const { systems, unfetched, stale } = marketplaceDesignSystems(home);
340
+ const rows = systems.filter((s) => !s.missing).map((s) => {
341
+ const r = resolveDesignSystemRef(s.qualified, home);
342
+ let title = typeof r.entry?.title === 'string' ? r.entry.title.trim() : '';
343
+ if (!title && r.dir) {
344
+ try { title = String(JSON.parse(fs.readFileSync(path.join(r.dir, 'design-system.json'), 'utf8')).title ?? '').trim(); } catch { /* the gate's to report */ }
345
+ }
346
+ return { name: s.name, marketplace: s.marketplace, qualified: s.qualified, title: title || s.name, version: s.version, description: s.description };
347
+ });
348
+ return { systems: rows, unfetched, stale };
349
+ } catch { return { systems: [], unfetched: [], stale: [] }; }
350
+ }
351
+
352
+ /**
353
+ * `--design-system <ref>`, resolved as `design-system add` resolves one: a
354
+ * bare name or `name@marketplace` against the cached catalogs. Returns the
355
+ * qualified reference, or throws a message listing what the catalogs offer.
356
+ */
357
+ export async function resolveDesignSystemFlag(ref, home = configHome()) {
358
+ const { loadRegistry, loadCatalog, resolveEntry } = await import('./marketplace.mjs');
359
+ const offered = async () => {
360
+ const { systems } = await availableDesignSystems(home);
361
+ return systems.length ? ` — the cached catalogs offer: ${systems.map((s) => s.qualified).join(', ')}`
362
+ : ' — no cached catalog offers a design system (decklight design-system list)';
363
+ };
364
+ const cats = {};
365
+ try {
366
+ for (const name of Object.keys(loadRegistry(home).marketplaces ?? {})) {
367
+ const c = loadCatalog(name, home);
368
+ if (c?.ok) cats[name] = c.manifest;
369
+ }
370
+ } catch (e) { throw new Error(`--design-system: ${e.message}`); }
371
+ let hit;
372
+ try { hit = resolveEntry(ref, cats); } catch (e) { throw new Error(`--design-system: ${e.message}${await offered()}`); }
373
+ if (hit.entry.type !== 'design-system') throw new Error(`--design-system: ${hit.qualified} is a ${hit.entry.type}, not a design system${await offered()}`);
374
+ return hit.qualified;
375
+ }
376
+
377
+ /**
378
+ * The starter deck, built on a design system: exactly what `design-system
379
+ * add <ref> <deck> --apply` writes, composed on the starter HTML before init's
380
+ * one write. The gate first, then the reference and its source, the themes
381
+ * and fonts it recommends, and its look (its own first theme, else the first
382
+ * recommended one the deck can apply, and the first recommended font). The
383
+ * title slide is its first template with a heading-hinted slot, carrying the
384
+ * title (`titleSlideTemplate`, the insert path's slot filling). `build(slide)`
385
+ * is the starter for a title slide (null: today's). Returns `{ html, label,
386
+ * installs, warnings }`; throws an Error whose message says why it could not.
387
+ */
388
+ export async function wireDesignSystem(build, qualified, { home = configHome(), titleHtml }) {
389
+ const { resolveDesignSystemRef, setDesignSystem } = await import('./design-system-refs.mjs');
390
+ const { checkDir } = await import('./design-system.mjs');
391
+ const { refForDeck } = await import('./theme-refs.mjs');
392
+ const { loadRegistry } = await import('./marketplace.mjs');
393
+ const deps = await import('./design-system-deps.mjs');
394
+ const { titleSlideTemplate } = await import('./design-system-edit.mjs');
395
+ const r = resolveDesignSystemRef(qualified, home);
396
+ if (!r.dir) throw new Error(r.missing);
397
+ const verdict = checkDir(r.dir);
398
+ if (!verdict.ok) {
399
+ const p = verdict.problems[0];
400
+ throw new Error(`it no longer passes its gate (${p.file}${p.line ? ` line ${p.line}` : ''}: ${p.msg}; decklight design-system gate ${r.dir})`);
401
+ }
402
+ const slide = titleSlideTemplate(verdict.manifest.name, verdict.summary?.templates ?? [], titleHtml);
403
+ let html = build(slide);
404
+ const deckRef = refForDeck(html, r.name, r.local, r.source ?? null);
405
+ html = setDesignSystem(html, deckRef, true, { source: r.source ?? null, version: verdict.manifest.version }).html;
406
+ const plan = deps.planRecommended(html, { manifest: verdict.manifest, local: r.local }, home);
407
+ html = deps.writePlan(html, plan);
408
+ const look = deps.lookOf(html, plan);
409
+ if (look.differs) html = deps.applyLook(html, look);
410
+ const commit = loadRegistry(home).marketplaces?.[r.local]?.commit ?? null;
411
+ const installs = [
412
+ { type: 'design-system', name: r.name, marketplace: r.local, version: r.entry.version ?? null, commit },
413
+ ...deps.plannedInstalls(plan, home),
414
+ ];
415
+ const theme = configBlock(html)?.config?.theme;
416
+ const family = plan.items.find((it) => it.kind === 'font' && it.name === look.font)?.family ?? look.font;
417
+ const version = verdict.summary?.version ?? verdict.manifest.version;
418
+ const label = `design system: ${verdict.manifest.title || r.name}${version ? ` ${version}` : ''} — theme ${theme}`
419
+ + `${look.font ? `, font ${family}` : ''}${slide ? ` · title slide on ${slide.ref}` : ''}`;
420
+ const warnings = deps.planLines({ ...plan, items: plan.items.filter((it) => it.status === 'skip') });
421
+ return { html, label, installs, warnings, deckRef };
422
+ }
423
+
297
424
  // ── the skill scope: project by default, global as a proposition ────────────
298
425
  // The same shape as planGit: a pure decision table over flags and the TTY
299
426
  // gate. --no-skill skips skill AND question, --global-skill preselects the
@@ -351,69 +478,37 @@ export function epilogue({ deckPath, tty = false, noColor = false }) {
351
478
  return [
352
479
  '',
353
480
  ` ${a('open to present')} ${color ? osc8(url) : url}`,
354
- ` ${a('start editing')} decklight author ${deck}`,
481
+ ` ${a('start editing')} decklight ${deck}`,
355
482
  '',
356
483
  ].join('\n') + '\n';
357
484
  }
358
485
 
359
- // ── --open: hand the deck's file:// URL to the platform launcher ────────────
360
-
361
- /**
362
- * Platform → launcher invocation for a URL, as pure data so it can be tested
363
- * without spawning anything. macOS ships `open`; Windows goes through cmd's
364
- * `start` builtin (the empty '' fills the window-title slot, or the URL would
365
- * become the title); everything else gets freedesktop's xdg-open. Zero new
366
- * dependencies by design.
367
- */
368
- export function openCommand(platform, url) {
369
- if (platform === 'darwin') return { cmd: 'open', args: [url] };
370
- if (platform === 'win32') return { cmd: 'cmd', args: ['/c', 'start', '', url] };
371
- return { cmd: 'xdg-open', args: [url] };
372
- }
373
-
374
- /**
375
- * Launch the default browser on the deck's file:// URL — the deck is
376
- * self-contained, so the file IS the presentation. Spawned detached with
377
- * stdio ignored (the dev.mjs idiom) so init exits promptly. A machine that
378
- * cannot launch (headless, no xdg-open) gets one dim line and a normal exit:
379
- * the deck was created, which is the product.
380
- */
381
- export async function openDeck(deckPath, opts = {}) {
382
- const rel = path.relative('.', deckPath) || deckPath;
383
- // the prefix names the FLAG that asked, which is what a reader of the line
384
- // needs: --open is opt-in, and its one dim failure line has to say so
385
- return openUrl(pathToFileURL(deckPath).href, { ...opts, what: rel, prefix: '--open: ' });
386
- }
387
-
388
- /**
389
- * The same launcher, for a URL that is not a file — `decklight record` serves
390
- * the deck over http://127.0.0.1 precisely because a browser will not open a
391
- * microphone for a `file://` page.
392
- */
393
- export async function openUrl(url, {
394
- platform = process.platform, spawnFn = spawn, out = process.stdout, what = url, prefix = '',
395
- } = {}) {
396
- const { cmd, args } = openCommand(platform, url);
397
- const rel = what;
398
- const dim = (s) => (out.isTTY && !process.env.NO_COLOR ? `${DIM}${s}${RESET}` : s);
399
- const skipped = (err) =>
400
- out.write(dim(`${prefix}could not launch a browser (${cmd}: ${err.code ?? err.message}) — open ${rel} yourself\n`));
401
- await new Promise((resolve) => {
402
- let child;
403
- try {
404
- child = spawnFn(cmd, args, { stdio: 'ignore', detached: true });
405
- } catch (err) { skipped(err); resolve(); return; }
406
- child.once('error', (err) => { skipped(err); resolve(); });
407
- child.once('spawn', () => {
408
- child.unref();
409
- out.write(`opening ${rel} in your default browser\n`);
410
- resolve();
411
- });
412
- });
413
- }
414
486
 
415
- function starterDeck(title, themeNames, activeTheme) {
487
+ function starterDeck(title, themeNames, activeTheme, { inline = false, titleSlide = null } = {}) {
416
488
  title = escapeHtml(title); // a prompt invites &, < and quotes
489
+ // The deck is DATA (#520): slides, plus one JSON block holding its
490
+ // configuration and the version it was written for. No runtime in the file
491
+ // — `open`, `--no-trust` and every render reference the installed one on
492
+ // the way out, and `bundle` embeds it at hand-over. A few KB of slides, a
493
+ // git history that is only slides, and nothing in the file that executes.
494
+ // `--inline` is the self-contained scaffold: double-clickable, pinned to
495
+ // this version, 650 KB before the first slide.
496
+ if (!inline) {
497
+ return `<!doctype html>
498
+ <html lang="en">
499
+ <head>
500
+ <meta charset="utf-8">
501
+ <title>${title}</title>
502
+ ${configBlockHtml({ theme: activeTheme })}
503
+ </head>
504
+ <body>
505
+ <div class="decklight">
506
+ ${starterSlides(title, titleSlide)}
507
+ </div>
508
+ </body>
509
+ </html>
510
+ `;
511
+ }
417
512
  const css = runtimeCss();
418
513
  // one <style data-theme> per theme; only the active one applies (the rest
419
514
  // carry media="not all", which the runtime's inline-theme mode toggles).
@@ -434,10 +529,29 @@ ${themeBlocks}
434
529
  </head>
435
530
  <body>
436
531
  <div class="decklight">
532
+ ${starterSlides(title)}
533
+ </div>
534
+ <script data-decklight-runtime="js">${runtimeJs()}</script>
535
+ <script>Decklight.init({});</script>
536
+ </body>
537
+ </html>
538
+ `;
539
+ }
437
540
 
438
- <section>
541
+ /**
542
+ * The two starter slides, shared by the linked and the self-contained
543
+ * scaffold. `title` is already escaped. `titleSlide` (`titleSlideTemplate`)
544
+ * puts the title slide on a design system's template; the build slide is the
545
+ * same either way: it teaches the one concept every deck needs, on any theme.
546
+ */
547
+ function starterSlides(title, titleSlide = null) {
548
+ const open = titleSlide
549
+ ? `<section data-template="${titleSlide.ref}">\n${titleSlide.lines.map((l) => ` ${l}`).join('\n')}`
550
+ : `<section>
439
551
  <h1>${title}</h1>
440
- <p>Made with Decklight — press → to advance, ? for every key</p>
552
+ <p>Made with Decklight — press → to advance, ? for every key</p>`;
553
+ return `
554
+ ${open}
441
555
  <aside class="notes">
442
556
  <p>Welcome. This is the title slide — say a line or two about what this deck covers.</p>
443
557
  </aside>
@@ -448,22 +562,18 @@ ${themeBlocks}
448
562
  <ul data-build="fade-up">
449
563
  <li>One attribute on the container: <code>data-build</code></li>
450
564
  <li>Each direct child becomes one build step, in document order</li>
451
- <li>Speaker notes segment with ⟨CLICK⟩ to match — see below</li>
565
+ <li>Speaker notes segment with [click] to match — see below</li>
452
566
  </ul>
453
567
  <aside class="notes">
568
+ <p>This slide shows its points one at a time.</p>
569
+ <p>[click]</p>
454
570
  <p>The container opts in and the engine does the rest — not a single class on the items themselves.</p>
455
- <p>⟨CLICK⟩</p>
571
+ <p>[click]</p>
456
572
  <p>Every press of the arrow reveals the next one, in order.</p>
457
- <p>⟨CLICK⟩</p>
458
- <p>And that's it — replace this slide's content, duplicate the section for more, and you have a deck.</p>
573
+ <p>[click]</p>
574
+ <p>And the notes are cut the same way, one beat before the first point and one per point, so the voice says each as it appears. Replace this slide's content, duplicate the section for more, and you have a deck.</p>
459
575
  </aside>
460
576
  </section>
461
-
462
- </div>
463
- <script data-decklight-runtime="js">${runtimeJs()}</script>
464
- <script>Decklight.init({});</script>
465
- </body>
466
- </html>
467
577
  `;
468
578
  }
469
579
 
@@ -472,30 +582,54 @@ export async function initMain(argv = process.argv.slice(2), { hasBin = onPath,
472
582
  process.stdout.write(`decklight init — scaffold a starter deck + agent skill
473
583
 
474
584
  Usage:
475
- decklight init ["Deck Title"] [-o deck.html] [--dir path] [--themes …]
476
- [--from <template>] [--git | --no-git] [--open] [--force]
585
+ decklight init ["Deck Title"] [-o deck.html] [--dir path] [--inline [--themes …]]
586
+ [--design-system <ref> | --no-design-system]
587
+ [--git | --no-git] [--remote <url> | --no-remote] [--no-open] [--force]
477
588
  [--no-skill | --global-skill]
478
589
 
479
590
  Options:
480
591
  -o <file> deck output path (default: deck.html)
481
592
  --dir <path> target directory (default: current directory)
482
- --from <name> scaffold from an installed deck template instead of the
483
- starter deck (decklight template list). The title argument
484
- replaces the template's <title> and first <h1>; everything
485
- else is the template's. Not installed? init names the
486
- install command rather than fetching — installing is its own
487
- step, and init does not reach the network.
488
- Cannot be combined with --themes: a template brings its own.
489
- --themes <sel> which themes to inline into the deck:
593
+ --inline a self-contained deck: runtime and themes embedded, so it
594
+ opens from disk without decklight — pinned to this version,
595
+ ~650 KB before the first slide. The default is slides plus
596
+ a JSON configuration block and no runtime in the file:
597
+ decklight serves the installed runtime into it, and
598
+ \`decklight bundle\` embeds it when the deck is handed over.
599
+ --themes <sel> with --inline, which themes to embed:
490
600
  all every shipped theme (default)
491
601
  name,name,… an explicit list (aurora stays active when
492
602
  included, else the first listed)
603
+ --design-system <ref>
604
+ start the deck on a design system a registered marketplace
605
+ offers (name or name@marketplace, read from the cached
606
+ catalogs: nothing is fetched). The deck references it and
607
+ takes what \`decklight design-system add <ref> <deck> --apply\`
608
+ gives: its recommended themes and fonts, its theme and font,
609
+ and a title slide on its first template with a heading slot.
610
+ Refused with --inline: a file opened from disk has no server
611
+ to link a design system (\`decklight bundle\` embeds one).
612
+ (a cached catalog lists one + no flag: init ASKS on a TTY,
613
+ and off a terminal names them in one line)
614
+ --no-design-system
615
+ decklight's own themes; asks nothing about a design system
493
616
  --git create a git repository (with a starter .gitignore) and
494
617
  commit everything init wrote
495
618
  (outside a repo + no flag: init ASKS on a TTY)
496
619
  --no-git never touch git
497
- --open open the scaffolded deck in your default browser
498
- (the deck is self-contained — the file is the presentation)
620
+ --remote <url> add it as origin to the repository init creates, and push
621
+ (without it, a terminal run offers a private GitHub
622
+ repository when gh is signed in, or asks for a URL)
623
+ --no-remote create the repository, and ask nothing about a remote
624
+ --no-open start the deck without opening the browser. Once the deck
625
+ is written, init opens it: the default deck in write mode
626
+ (live reload, edits from the browser, an AI agent on A), a
627
+ self-contained --inline deck as a file in your browser.
628
+ --no-open starts the write-mode server and leaves the
629
+ browser to you. Off a terminal init only prints the
630
+ command (a server nobody can stop is never started), and
631
+ opens a self-contained deck's file only when --open is
632
+ typed.
499
633
  --force overwrite an existing deck file (default: refuses)
500
634
  --no-skill skip the agent skill entirely (project and global), and the
501
635
  where-should-it-go question with it
@@ -519,27 +653,37 @@ unless --no-skill is given. The deck file is only touched with --force.
519
653
  return 0;
520
654
  }
521
655
 
522
- let title = null, outFile = 'deck.html', dir = '.', force = false, themesSel = 'all', openAfter = false;
523
- let from = null;
656
+ let title = null, outFile = 'deck.html', dir = '.', force = false, themesSel = 'all', inline = false;
524
657
  const args = [...argv];
525
658
  for (let i = 0; i < args.length; i++) {
526
659
  const a = args[i];
527
660
  if (a === '-o') outFile = args[++i];
528
661
  else if (a === '--dir') dir = args[++i];
529
- else if (a === '--from') from = args[++i];
530
662
  else if (a === '--themes') themesSel = args[++i];
663
+ else if (a === '--inline') inline = true;
531
664
  else if (a === '--force') force = true;
532
- else if (a === '--open') openAfter = true;
665
+ else if (a === '--open' || a === '--no-open') ; // the handoff, below (--open is the default)
533
666
  else if (a === '--no-skill' || a === '--global-skill') ; // consumed by planSkill below
534
667
  else if (a === '--git' || a === '--no-git') ; // consumed by planGit below
535
668
  else if (a === '--remote') i++; // consumed by planRemote below
536
669
  else if (a === '--no-remote') ; // likewise
670
+ else if (a === '--design-system') i++; // consumed by planDesignSystem below
671
+ else if (a === '--no-design-system') ; // likewise
537
672
  else if (!a.startsWith('-')) title = title ?? a;
538
673
  else fail(`unknown argument: ${a}`);
539
674
  }
540
675
  if (argv.includes('--no-skill') && argv.includes('--global-skill')) {
541
676
  fail('--no-skill and --global-skill are mutually exclusive');
542
677
  }
678
+ // a refusal, or a --design-system no cached catalog has, fails here: before
679
+ // a question is asked or a file written
680
+ const home = configHome(env);
681
+ let ds = planDesignSystem({ args: argv, inline });
682
+ if (ds.action === 'refuse') fail(ds.why);
683
+ let dsRef = null;
684
+ if (ds.action === 'use') {
685
+ try { dsRef = await resolveDesignSystemFlag(ds.ref, home); } catch (e) { fail(e.message); }
686
+ }
543
687
 
544
688
  // ONE readline interface for every question this run asks (title, git,
545
689
  // handoff). Lines arriving BETWEEN questions (answers typed ahead) are
@@ -551,20 +695,22 @@ unless --no-skill is given. The deck file is only touched with --force.
551
695
  rl?.on('line', (l) => typedAhead.push(l)); // only fires with no question pending
552
696
  let stdinGone = false;
553
697
  rl?.once('close', () => { stdinGone = true; });
554
- const question = (q) => {
698
+ // `{ answer, eof }`: an empty answer is Enter, unless the input has ended
699
+ const ask = (q) => {
555
700
  if (typedAhead.length) {
556
701
  const answer = typedAhead.shift();
557
702
  process.stdout.write(q + answer + '\n'); // the transcript still records the decision
558
- return Promise.resolve(answer);
703
+ return Promise.resolve({ answer, eof: false });
559
704
  }
560
- if (!rl || stdinGone) return Promise.resolve('');
705
+ if (!rl || stdinGone) return Promise.resolve({ answer: '', eof: true });
561
706
  // rl.question's promise never settles when the input ends mid-question
562
707
  // (observed on Node 20), so the close event doubles as the empty answer
563
708
  return new Promise((res) => {
564
- rl.once('close', () => res(''));
565
- rl.question(q).then(res, () => res(''));
709
+ rl.once('close', () => res({ answer: '', eof: true }));
710
+ rl.question(q).then((answer) => res({ answer, eof: false }), () => res({ answer: '', eof: true }));
566
711
  });
567
712
  };
713
+ const question = async (q) => (await ask(q)).answer;
568
714
  // `defaultYes` is what a bare Enter means. It is a parameter rather than a
569
715
  // constant because the remote question flips it: for a directory decklight
570
716
  // scaffolded the answer is almost certainly yes, and for one that already
@@ -576,15 +722,8 @@ unless --no-skill is given. The deck file is only touched with --force.
576
722
  return defaultYes ? !/^n/i.test(a) : /^y/i.test(a);
577
723
  };
578
724
 
579
- if (from && themesSel !== 'all') {
580
- // A template carries its own themes — it is a whole deck, not a body to
581
- // dress. Silently ignoring --themes would be the kind of no-op that gets
582
- // reported as a bug six months later.
583
- fail('--from and --themes are mutually exclusive — a template brings its own themes');
584
- }
585
-
586
725
  title = await resolveTitle(title, { isTTY: tty, ask: question });
587
- const themeNames = resolveThemes(from ? 'all' : themesSel);
726
+ const themeNames = resolveThemes(themesSel);
588
727
  const activeTheme = themeNames.includes(STARTER_THEME) ? STARTER_THEME : themeNames[0];
589
728
 
590
729
  const root = path.resolve(dir);
@@ -608,24 +747,52 @@ unless --no-skill is given. The deck file is only touched with --force.
608
747
  }
609
748
  fail(`${rel} already exists — pass --force to overwrite`);
610
749
  }
611
- let body, themeNote;
612
- if (from) {
613
- const { findUnit, catalogEntriesOfType } = await import('./units.mjs');
614
- const found = templateDeck(from, {
615
- listInstalled: (name, home) => findUnit('template', name, home),
616
- offered: (home) => catalogEntriesOfType('template', home),
617
- });
618
- if (!found.ok) fail(found.message);
619
- body = titleTemplate(found.html, title);
620
- themeNote = `from template ${from}`;
621
- } else {
622
- body = starterDeck(title, themeNames, activeTheme);
623
- themeNote = themeNames.length === 1
750
+ // ── the design system: asked right after the title, wired before the write
751
+ const deckRel = path.relative('.', deckPath) || outFile;
752
+ if (ds.action === 'skip' && !inline && !argv.includes('--no-design-system')) {
753
+ ds = planDesignSystem({ args: argv, tty, inline, ...(await availableDesignSystems(home)) });
754
+ }
755
+ if (ds.action === 'ask') {
756
+ const { lines, prompt } = designSystemQuestion(ds, { color });
757
+ for (const l of lines) process.stdout.write(`${l}\n`);
758
+ for (;;) {
759
+ const { answer, eof } = await ask(prompt);
760
+ const r = pickDesignSystem(answer, ds, { eof });
761
+ if (r.again) continue;
762
+ dsRef = r.pick?.qualified ?? null;
763
+ break;
764
+ }
765
+ }
766
+ const plainNote = 'slides and a config block, no runtime in the file — decklight bundle embeds it to send';
767
+ let body = starterDeck(title, themeNames, activeTheme, { inline });
768
+ let themeNote = !inline ? `theme: ${activeTheme} · ${plainNote}`
769
+ : themeNames.length === 1
624
770
  ? `theme: ${themeNames[0]}`
625
771
  : `${themeNames.length} themes, ${activeTheme} active`;
772
+ let wired = null, dsNote = null;
773
+ if (dsRef) {
774
+ // a failure here costs a note and a plain deck, never the scaffold
775
+ try {
776
+ wired = await wireDesignSystem((titleSlide) => starterDeck(title, themeNames, activeTheme, { titleSlide }),
777
+ dsRef, { home, titleHtml: escapeHtml(title) });
778
+ body = wired.html;
779
+ themeNote = `${wired.label} · ${plainNote}`;
780
+ } catch (e) {
781
+ dsNote = ` design system: ${dsRef} not wired in — ${String(e?.message ?? e).replace(/\s+/g, ' ')}; the deck starts plain`
782
+ + ` (decklight design-system add ${dsRef} ${deckRel} --apply retries)`;
783
+ }
626
784
  }
627
785
  fs.writeFileSync(deckPath, body);
628
- note(`created ${path.relative('.', deckPath) || outFile} (${themeNote})`);
786
+ note(`created ${deckRel} (${themeNote})`);
787
+ if (dsNote) note(dsNote);
788
+ if (ds.action === 'hint') note(designSystemHint(ds.systems));
789
+ if (wired) {
790
+ for (const l of wired.warnings) note(l);
791
+ try {
792
+ const { recordInstall } = await import('./marketplace.mjs');
793
+ for (const inst of wired.installs) recordInstall(inst, home);
794
+ } catch (e) { note(` design system: the deck uses it, but installed.json could not record it — ${oneline(e)}`); }
795
+ }
629
796
 
630
797
  // ── the skill — project scope by default, global as a proposition ────────
631
798
  let skill = planSkill({ args: argv, tty }).action;
@@ -654,9 +821,13 @@ unless --no-skill is given. The deck file is only touched with --force.
654
821
  fs.writeFileSync(path.join(skillDir, 'SKILL.md'), claudeSkillMd());
655
822
  fs.writeFileSync(path.join(skillDir, 'reference.md'), referenceDoc());
656
823
  note(`wrote .claude/skills/decklight/{SKILL.md,reference.md} (v${PKG.version})`);
824
+ // the marketplace skills in your library go beside it (#880)
825
+ const handedOn = [];
826
+ syncLibrarySkills(path.join(root, '.claude', 'skills'), handedOn);
827
+ for (const line of handedOn.filter(Boolean)) note(line);
657
828
 
658
829
  const agentsPath = path.join(root, 'AGENTS.md');
659
- const section = agentsSection();
830
+ const section = agentsSection(undefined, { librarySkills: librarySkills() });
660
831
  if (!fs.existsSync(agentsPath)) {
661
832
  fs.writeFileSync(agentsPath, `# Agent notes\n\n${section}`);
662
833
  note('created AGENTS.md');
@@ -677,33 +848,17 @@ unless --no-skill is given. The deck file is only touched with --force.
677
848
  const plan = planGit({ args: argv, tty, inRepo: inGitRepo(root) });
678
849
  let { action } = plan;
679
850
  if (action === 'ask') {
680
- action = (await askYes(' create a git repository so your edits are auto-committed? [Y/n] '))
851
+ action = (await askYes(' create a git repository so every version of the deck is kept? [Y/n] '))
681
852
  ? 'create' : 'skip';
682
853
  }
683
854
  if (action === 'create') {
684
855
  note(initRepo(root));
685
856
  // Stated, not asked: the mode is already the default, so a fifth prompt
686
857
  // would only offer what is on. The line names the flag that turns it off.
687
- note(" commits land one per agent edit, with the agent's own message"
688
- + ' (--git-mode timer for a plain cadence)');
689
- // …and the OTHER half of what those commits say. Asked here, once, because
690
- // this is the moment the commits it governs start existing — and asked at
691
- // all, rather than defaulted silently, because the answer sends the deck's
692
- // diffs to an agent. Default yes; a person still has to let it through.
693
- const msgs = planCommitMessages({
694
- args: argv, tty, agents: detectAgents().length, creatingRepo: true,
695
- stored: storedPref(root),
696
- });
697
- if (msgs.action === 'ask' || msgs.action === 'on' || msgs.action === 'off') {
698
- const on = msgs.action === 'ask' ? await askYes(ASK_MESSAGES, true) : msgs.action === 'on';
699
- rememberPref(root, on);
700
- note(on
701
- ? ' commit subjects are written by an agent, from the diff'
702
- + ' (git config decklight.commit-messages false turns it off)'
703
- : ' commit subjects stay generic (--commit-messages turns it on)');
704
- }
858
+ note(' your edits are snapshotted as you go and committed when you press K;'
859
+ + " an agent's edit commits itself, with its own message (--git-mode timer for a plain cadence)");
705
860
  }
706
- else if (action === 'hint') note(' git: no repository here — pass --git to create one and auto-commit the deck');
861
+ else if (action === 'hint') note(' git: no repository here — pass --git to create one and keep every version of the deck');
707
862
 
708
863
  // ── the remote offer — the deck exists nowhere else until this happens ───
709
864
  // ONLY for a repository decklight just created. A repo that was already here
@@ -735,17 +890,33 @@ unless --no-skill is given. The deck file is only touched with --force.
735
890
 
736
891
  process.stdout.write(epilogue({ deckPath, tty: !!process.stdout.isTTY, noColor: !!process.env.NO_COLOR }));
737
892
 
738
- // last of the writes, so every "created/wrote" line is on screen before the
739
- // browser steals focus; opens the deck FILE, not a served URL — the deck is
740
- // self-contained by design
741
- if (openAfter) await openDeck(deckPath);
742
-
743
- // No handoff. init scaffolds and gets out of the way: the epilogue above
744
- // prints `decklight author <deck>` under "start editing", and that command IS
745
- // the handoff. Starting a server for you means init does not return until
746
- // you stop it — you cannot look at what it made, or read the lines it just
747
- // printed, without first killing something.
893
+ // ── the handoff: the deck opens ───────────────────────────────────────────
894
+ // The epilogue names the command, and on a terminal init runs it, because
895
+ // the deck opened as a FILE is one where E, A and L all answer "needs
896
+ // decklight <deck>": the newcomer's first three keystrokes would hit the one
897
+ // command they have not seen yet. `--no-open` keeps the browser closed and
898
+ // nothing else: the server still starts. A run that is not on a terminal —
899
+ // a script, an agent, CI — never has a server started for it, since nobody
900
+ // is there to stop one; the epilogue is the whole handoff there. Everything
901
+ // init printed stays on screen above the deck's banner.
748
902
  rl?.close();
903
+ const noOpen = argv.includes('--no-open');
904
+ // A self-contained --inline deck IS the
905
+ // presentation: there is no server to hand it to, so it opens as a file —
906
+ // last of the writes, so every "created/wrote" line is on screen before
907
+ // the browser steals focus. Off a terminal only a typed --open opens it:
908
+ // a browser nobody asked for is not what a script wants.
909
+ if (inline) {
910
+ if (!noOpen && (tty || argv.includes('--open'))) await openDeck(deckPath);
911
+ return undefined;
912
+ }
913
+ if (!tty) return undefined;
914
+ const rel = path.relative(root, deckPath);
915
+ const cli = fileURLToPath(new URL('./decklight.mjs', import.meta.url));
916
+ // the banner has been printed once, by this run; the child is the same version
917
+ const r = spawnSync(process.execPath, [cli, ...handoffArgs({ rel, argv, gitPlan: plan.action, gitAction: action, noOpen })],
918
+ { stdio: 'inherit', cwd: root, env: { ...process.env, DECKLIGHT_BANNER: '1' } });
919
+ return r.status ?? 0;
749
920
  }
750
921
 
751
922
  if (isMain(import.meta.url)) process.exitCode = await runMain('init', initMain);