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
package/cli/init.mjs CHANGED
@@ -7,77 +7,77 @@
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';
44
+ import { configBlock, configBlockHtml, configVersion, hasRuntime } from './runtime-link.mjs';
50
45
  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';
46
+ import { onPath } from './agents.mjs';
55
47
  import { escapeHtml } from './edit.mjs';
56
48
  import {
57
49
  classifyRemoteError, createRepo, foreignWarning, git as gitRun, inGitRepo, isIdentityError,
58
50
  looksLikeGitUrl, noPromptEnv, oneline, remoteNames, splitDeckPaths,
59
51
  } from './git.mjs';
60
52
  import { makeFail, runMain } from './util.mjs';
53
+ import { configHome } from './marketplace.mjs';
54
+ import { openCommand, openDeck, openUrl } from './open-browser.mjs';
55
+
56
+ // still exported from here — record and review used to import the opener from init
57
+ export { openCommand, openDeck, openUrl };
61
58
  import { isMain } from '../tools/args.mjs';
62
59
 
63
60
  const fail = makeFail('init');
64
61
 
65
62
  /**
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
63
+ * Is this HTML a decklight deck, and which runtime was it written for?
64
+ * Keys on the `class="decklight"` stage div plus one of the three things a
65
+ * deck boots by: a `Decklight.init(` call, a configuration block (#520), or a
66
+ * runtime in the file. The version comes from the bundle's
69
67
  * `/*! Decklight vX.Y.Z … ` banner (stamped by build.mjs; minification makes
70
- * the exported const unfindable).
68
+ * the exported const unfindable), a linked deck's `data-decklight-version`
69
+ * (#517), or the block's `decklight` key.
71
70
  *
72
71
  * @returns the runtime version string; `null` for a decklight deck whose
73
72
  * version can't be extracted; `undefined` for a non-deck.
74
73
  */
75
74
  export function deckRuntimeVersion(html) {
76
75
  const isDeck = /<[a-z][^>]*\bclass=["'](?:[^"']*\s)?decklight(?:\s[^"']*)?["']/i.test(html)
77
- && /Decklight\.init\s*\(/.test(html);
76
+ && (/Decklight\.init\s*\(/.test(html) || !!configBlock(html) || hasRuntime(html));
78
77
  if (!isDeck) return undefined;
79
- const banner = /\/\*!\s*Decklight v(\d+\.\d+\.\d+[^\s*]*)/.exec(html);
80
- return banner ? banner[1] : null;
78
+ const banner = /\/\*!\s*Decklight v(\d+\.\d+\.\d+[^\s*]*)/.exec(html)
79
+ ?? /<script\b[^>]*\bsrc=["'][^"']*decklight[^"']*\.js["'][^>]*\bdata-decklight-version=["']([^"']+)["']/i.exec(html);
80
+ return banner ? banner[1] : configVersion(html);
81
81
  }
82
82
 
83
83
  // aurora is the deck's starting look; init ships every theme by default so the
@@ -102,60 +102,6 @@ function resolveThemes(sel) {
102
102
  return names;
103
103
  }
104
104
 
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
105
 
160
106
  // No title argument: ask on a TTY (the one thing every run would have passed
161
107
  // had the author known), scaffold the default silently everywhere else.
@@ -167,7 +113,7 @@ export async function resolveTitle(arg, { isTTY = false, ask } = {}) {
167
113
  }
168
114
 
169
115
  // ── git: offer the repository at the natural moment ─────────────────────────
170
- // The same policy `decklight author` applies later, decided here as a pure
116
+ // The same policy `decklight <deck>` applies later, decided here as a pure
171
117
  // function so the table (--git / --no-git / TTY / repo-present) is testable
172
118
  // without a repository or a terminal.
173
119
  export function planGit({ args = [], tty = false, inRepo = false } = {}) {
@@ -177,6 +123,19 @@ export function planGit({ args = [], tty = false, inRepo = false } = {}) {
177
123
  return { action: tty ? 'ask' : 'hint' };
178
124
  }
179
125
 
126
+ /**
127
+ * The arguments init hands to `decklight <deck>` once the deck is written.
128
+ *
129
+ * The git answer travels with them. Without it, a "no" to init's git question
130
+ * left the directory without a repository, and the deck it opened found none
131
+ * and asked the same question again a second later. `--no-git` typed to init
132
+ * travels too: "never touch git" is the person's, not one command's.
133
+ */
134
+ export function handoffArgs({ rel, argv = [], gitPlan, gitAction, noOpen = false }) {
135
+ const declined = argv.includes('--no-git') || (gitPlan === 'ask' && gitAction === 'skip');
136
+ return [rel, ...(declined ? ['--no-git'] : []), ...(noOpen ? [] : ['--open'])];
137
+ }
138
+
180
139
  /** Everything committed here that is not the deck — what a push would carry. */
181
140
  export function notTheDeck(root, deckPath, run = gitRun) {
182
141
  try {
@@ -294,6 +253,173 @@ export function planRemote({
294
253
  return { action: ghReady ? 'ask-gh' : 'ask-url', defaultYes: foreign === 0 };
295
254
  }
296
255
 
256
+ // ── the design system: a brand's deck starts on the brand ───────────────────
257
+ // Asked right after the title, and only when a CACHED catalog of a registered
258
+ // marketplace lists a design system this machine can resolve: nothing is
259
+ // fetched, so the question works on a plane and never slows init down. With
260
+ // none on offer there is no question and no new output. A pure table, like
261
+ // planGit: the rows are handed in, so it is testable without a marketplace.
262
+ export function planDesignSystem({ args = [], tty = false, inline = false, systems = [], unfetched = [], stale = [] } = {}) {
263
+ const i = args.indexOf('--design-system');
264
+ const ref = i >= 0 ? args[i + 1] : null;
265
+ const off = args.includes('--no-design-system');
266
+ if (i >= 0 && off) return { action: 'refuse', why: '--design-system and --no-design-system are mutually exclusive' };
267
+ if (i >= 0 && (!ref || ref.startsWith('-'))) return { action: 'refuse', why: '--design-system needs a design system (name or name@marketplace)' };
268
+ if (i >= 0 && inline) {
269
+ return { action: 'refuse', why: '--design-system cannot start an --inline deck: a self-contained file opened from disk has'
270
+ + ' no server to link a design system by reference (decklight bundle embeds one when the deck is handed over)' };
271
+ }
272
+ if (off) return { action: 'skip' };
273
+ if (ref) return { action: 'use', ref };
274
+ if (inline || !systems.length) return { action: 'skip' };
275
+ if (!tty) return { action: 'hint', systems };
276
+ return { action: 'ask', rows: systems, defaultIndex: systems.length === 1 ? 0 : null, unfetched, stale };
277
+ }
278
+
279
+ /**
280
+ * The question as printed: one row per design system (title, reference,
281
+ * version, and its description as a dim second line), `none` last, the
282
+ * marketplaces the cache cannot answer for as dim lines under it, and the
283
+ * prompt: `[1]:` when the one design system is the default, else the range.
284
+ */
285
+ export function designSystemQuestion(plan, { color = false } = {}) {
286
+ const dim = (s) => (color ? `${DIM}${s}${RESET}` : s);
287
+ const lines = ['design system for this deck?'];
288
+ plan.rows.forEach((r, n) => {
289
+ lines.push(` ${n + 1} ${r.title} — ${r.qualified}${r.version ? ` ${r.version}` : ''}`);
290
+ if (r.description) lines.push(dim(` ${r.description}`));
291
+ });
292
+ lines.push(` ${plan.rows.length + 1} none — decklight's own themes`);
293
+ for (const m of plan.unfetched ?? []) lines.push(dim(` ${m} has not been fetched yet — decklight marketplace update ${m}`));
294
+ for (const m of plan.stale ?? []) lines.push(dim(` ${m}'s cached catalog could not be read — decklight marketplace update ${m}`));
295
+ const prompt = plan.defaultIndex != null ? `[${plan.defaultIndex + 1}]: ` : `[1-${plan.rows.length + 1}]: `;
296
+ return { lines, prompt };
297
+ }
298
+
299
+ /**
300
+ * One answer to the question: `{ pick }` (a row, or null for none) or
301
+ * `{ again: true }`. Enter takes the default, and with no default asks again;
302
+ * a number, a name or `none` picks; anything else asks again. EOF picks none,
303
+ * as every init question degrades.
304
+ */
305
+ export function pickDesignSystem(answer, plan, { eof = false } = {}) {
306
+ const a = String(answer ?? '').trim();
307
+ if (!a) {
308
+ if (eof) return { pick: null };
309
+ return plan.defaultIndex != null ? { pick: plan.rows[plan.defaultIndex] } : { again: true };
310
+ }
311
+ if (/^\d+$/.test(a)) {
312
+ const n = Number(a);
313
+ if (n >= 1 && n <= plan.rows.length) return { pick: plan.rows[n - 1] };
314
+ if (n === plan.rows.length + 1) return { pick: null };
315
+ return { again: true };
316
+ }
317
+ if (/^none$/i.test(a)) return { pick: null };
318
+ const hits = plan.rows.filter((r) => r.qualified === a || r.name === a);
319
+ return hits.length === 1 ? { pick: hits[0] } : { again: true };
320
+ }
321
+
322
+ /** The one line a non-terminal run prints when a design system was on offer. */
323
+ export function designSystemHint(systems) {
324
+ return ` design system: none — this machine's marketplaces offer ${systems.map((s) => s.qualified).join(', ')};`
325
+ + ' --design-system <name@marketplace> starts a deck on one';
326
+ }
327
+
328
+ /**
329
+ * What the cached catalogs offer, as rows: every design-system entry this
330
+ * machine can resolve (one that needs a newer decklight, or whose checkout is
331
+ * gone, is left out), and the marketplaces the cache cannot answer for. Cache
332
+ * and checkouts only, never the network. A registry that does not read is
333
+ * nothing on offer: init is not the place to fail over it.
334
+ */
335
+ export async function availableDesignSystems(home = configHome()) {
336
+ try {
337
+ const { marketplaceDesignSystems, resolveDesignSystemRef } = await import('./design-system-refs.mjs');
338
+ const { systems, unfetched, stale } = marketplaceDesignSystems(home);
339
+ const rows = systems.filter((s) => !s.missing).map((s) => {
340
+ const r = resolveDesignSystemRef(s.qualified, home);
341
+ let title = typeof r.entry?.title === 'string' ? r.entry.title.trim() : '';
342
+ if (!title && r.dir) {
343
+ try { title = String(JSON.parse(fs.readFileSync(path.join(r.dir, 'design-system.json'), 'utf8')).title ?? '').trim(); } catch { /* the gate's to report */ }
344
+ }
345
+ return { name: s.name, marketplace: s.marketplace, qualified: s.qualified, title: title || s.name, version: s.version, description: s.description };
346
+ });
347
+ return { systems: rows, unfetched, stale };
348
+ } catch { return { systems: [], unfetched: [], stale: [] }; }
349
+ }
350
+
351
+ /**
352
+ * `--design-system <ref>`, resolved as `design-system add` resolves one: a
353
+ * bare name or `name@marketplace` against the cached catalogs. Returns the
354
+ * qualified reference, or throws a message listing what the catalogs offer.
355
+ */
356
+ export async function resolveDesignSystemFlag(ref, home = configHome()) {
357
+ const { loadRegistry, loadCatalog, resolveEntry } = await import('./marketplace.mjs');
358
+ const offered = async () => {
359
+ const { systems } = await availableDesignSystems(home);
360
+ return systems.length ? ` — the cached catalogs offer: ${systems.map((s) => s.qualified).join(', ')}`
361
+ : ' — no cached catalog offers a design system (decklight design-system list)';
362
+ };
363
+ const cats = {};
364
+ try {
365
+ for (const name of Object.keys(loadRegistry(home).marketplaces ?? {})) {
366
+ const c = loadCatalog(name, home);
367
+ if (c?.ok) cats[name] = c.manifest;
368
+ }
369
+ } catch (e) { throw new Error(`--design-system: ${e.message}`); }
370
+ let hit;
371
+ try { hit = resolveEntry(ref, cats); } catch (e) { throw new Error(`--design-system: ${e.message}${await offered()}`); }
372
+ if (hit.entry.type !== 'design-system') throw new Error(`--design-system: ${hit.qualified} is a ${hit.entry.type}, not a design system${await offered()}`);
373
+ return hit.qualified;
374
+ }
375
+
376
+ /**
377
+ * The starter deck, built on a design system: exactly what `design-system
378
+ * add <ref> <deck> --apply` writes, composed on the starter HTML before init's
379
+ * one write. The gate first, then the reference and its source, the themes
380
+ * and fonts it recommends, and its look (its own first theme, else the first
381
+ * recommended one the deck can apply, and the first recommended font). The
382
+ * title slide is its first template with a heading-hinted slot, carrying the
383
+ * title (`titleSlideTemplate`, the insert path's slot filling). `build(slide)`
384
+ * is the starter for a title slide (null: today's). Returns `{ html, label,
385
+ * installs, warnings }`; throws an Error whose message says why it could not.
386
+ */
387
+ export async function wireDesignSystem(build, qualified, { home = configHome(), titleHtml }) {
388
+ const { resolveDesignSystemRef, setDesignSystem } = await import('./design-system-refs.mjs');
389
+ const { checkDir } = await import('./design-system.mjs');
390
+ const { refForDeck } = await import('./theme-refs.mjs');
391
+ const { loadRegistry } = await import('./marketplace.mjs');
392
+ const deps = await import('./design-system-deps.mjs');
393
+ const { titleSlideTemplate } = await import('./design-system-edit.mjs');
394
+ const r = resolveDesignSystemRef(qualified, home);
395
+ if (!r.dir) throw new Error(r.missing);
396
+ const verdict = checkDir(r.dir);
397
+ if (!verdict.ok) {
398
+ const p = verdict.problems[0];
399
+ throw new Error(`it no longer passes its gate (${p.file}${p.line ? ` line ${p.line}` : ''}: ${p.msg}; decklight design-system gate ${r.dir})`);
400
+ }
401
+ const slide = titleSlideTemplate(verdict.manifest.name, verdict.summary?.templates ?? [], titleHtml);
402
+ let html = build(slide);
403
+ const deckRef = refForDeck(html, r.name, r.local, r.source ?? null);
404
+ html = setDesignSystem(html, deckRef, true, { source: r.source ?? null }).html;
405
+ const plan = deps.planRecommended(html, { manifest: verdict.manifest, local: r.local }, home);
406
+ html = deps.writePlan(html, plan);
407
+ const look = deps.lookOf(html, plan);
408
+ if (look.differs) html = deps.applyLook(html, look);
409
+ const commit = loadRegistry(home).marketplaces?.[r.local]?.commit ?? null;
410
+ const installs = [
411
+ { type: 'design-system', name: r.name, marketplace: r.local, version: r.entry.version ?? null, commit },
412
+ ...deps.plannedInstalls(plan, home),
413
+ ];
414
+ const theme = configBlock(html)?.config?.theme;
415
+ const family = plan.items.find((it) => it.kind === 'font' && it.name === look.font)?.family ?? look.font;
416
+ const version = verdict.summary?.version ?? verdict.manifest.version;
417
+ const label = `design system: ${verdict.manifest.title || r.name}${version ? ` ${version}` : ''} — theme ${theme}`
418
+ + `${look.font ? `, font ${family}` : ''}${slide ? ` · title slide on ${slide.ref}` : ''}`;
419
+ const warnings = deps.planLines({ ...plan, items: plan.items.filter((it) => it.status === 'skip') });
420
+ return { html, label, installs, warnings, deckRef };
421
+ }
422
+
297
423
  // ── the skill scope: project by default, global as a proposition ────────────
298
424
  // The same shape as planGit: a pure decision table over flags and the TTY
299
425
  // gate. --no-skill skips skill AND question, --global-skill preselects the
@@ -351,69 +477,37 @@ export function epilogue({ deckPath, tty = false, noColor = false }) {
351
477
  return [
352
478
  '',
353
479
  ` ${a('open to present')} ${color ? osc8(url) : url}`,
354
- ` ${a('start editing')} decklight author ${deck}`,
480
+ ` ${a('start editing')} decklight ${deck}`,
355
481
  '',
356
482
  ].join('\n') + '\n';
357
483
  }
358
484
 
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
485
 
415
- function starterDeck(title, themeNames, activeTheme) {
486
+ function starterDeck(title, themeNames, activeTheme, { inline = false, titleSlide = null } = {}) {
416
487
  title = escapeHtml(title); // a prompt invites &, < and quotes
488
+ // The deck is DATA (#520): slides, plus one JSON block holding its
489
+ // configuration and the version it was written for. No runtime in the file
490
+ // — `open`, `--no-trust` and every render reference the installed one on
491
+ // the way out, and `bundle` embeds it at hand-over. A few KB of slides, a
492
+ // git history that is only slides, and nothing in the file that executes.
493
+ // `--inline` is the self-contained scaffold: double-clickable, pinned to
494
+ // this version, 650 KB before the first slide.
495
+ if (!inline) {
496
+ return `<!doctype html>
497
+ <html lang="en">
498
+ <head>
499
+ <meta charset="utf-8">
500
+ <title>${title}</title>
501
+ ${configBlockHtml({ theme: activeTheme })}
502
+ </head>
503
+ <body>
504
+ <div class="decklight">
505
+ ${starterSlides(title, titleSlide)}
506
+ </div>
507
+ </body>
508
+ </html>
509
+ `;
510
+ }
417
511
  const css = runtimeCss();
418
512
  // one <style data-theme> per theme; only the active one applies (the rest
419
513
  // carry media="not all", which the runtime's inline-theme mode toggles).
@@ -434,10 +528,29 @@ ${themeBlocks}
434
528
  </head>
435
529
  <body>
436
530
  <div class="decklight">
531
+ ${starterSlides(title)}
532
+ </div>
533
+ <script data-decklight-runtime="js">${runtimeJs()}</script>
534
+ <script>Decklight.init({});</script>
535
+ </body>
536
+ </html>
537
+ `;
538
+ }
437
539
 
438
- <section>
540
+ /**
541
+ * The two starter slides, shared by the linked and the self-contained
542
+ * scaffold. `title` is already escaped. `titleSlide` (`titleSlideTemplate`)
543
+ * puts the title slide on a design system's template; the build slide is the
544
+ * same either way: it teaches the one concept every deck needs, on any theme.
545
+ */
546
+ function starterSlides(title, titleSlide = null) {
547
+ const open = titleSlide
548
+ ? `<section data-template="${titleSlide.ref}">\n${titleSlide.lines.map((l) => ` ${l}`).join('\n')}`
549
+ : `<section>
439
550
  <h1>${title}</h1>
440
- <p>Made with Decklight — press → to advance, ? for every key</p>
551
+ <p>Made with Decklight — press → to advance, ? for every key</p>`;
552
+ return `
553
+ ${open}
441
554
  <aside class="notes">
442
555
  <p>Welcome. This is the title slide — say a line or two about what this deck covers.</p>
443
556
  </aside>
@@ -448,22 +561,18 @@ ${themeBlocks}
448
561
  <ul data-build="fade-up">
449
562
  <li>One attribute on the container: <code>data-build</code></li>
450
563
  <li>Each direct child becomes one build step, in document order</li>
451
- <li>Speaker notes segment with ⟨CLICK⟩ to match — see below</li>
564
+ <li>Speaker notes segment with [click] to match — see below</li>
452
565
  </ul>
453
566
  <aside class="notes">
567
+ <p>This slide shows its points one at a time.</p>
568
+ <p>[click]</p>
454
569
  <p>The container opts in and the engine does the rest — not a single class on the items themselves.</p>
455
- <p>⟨CLICK⟩</p>
570
+ <p>[click]</p>
456
571
  <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>
572
+ <p>[click]</p>
573
+ <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
574
  </aside>
460
575
  </section>
461
-
462
- </div>
463
- <script data-decklight-runtime="js">${runtimeJs()}</script>
464
- <script>Decklight.init({});</script>
465
- </body>
466
- </html>
467
576
  `;
468
577
  }
469
578
 
@@ -472,30 +581,54 @@ export async function initMain(argv = process.argv.slice(2), { hasBin = onPath,
472
581
  process.stdout.write(`decklight init — scaffold a starter deck + agent skill
473
582
 
474
583
  Usage:
475
- decklight init ["Deck Title"] [-o deck.html] [--dir path] [--themes …]
476
- [--from <template>] [--git | --no-git] [--open] [--force]
584
+ decklight init ["Deck Title"] [-o deck.html] [--dir path] [--inline [--themes …]]
585
+ [--design-system <ref> | --no-design-system]
586
+ [--git | --no-git] [--remote <url> | --no-remote] [--no-open] [--force]
477
587
  [--no-skill | --global-skill]
478
588
 
479
589
  Options:
480
590
  -o <file> deck output path (default: deck.html)
481
591
  --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:
592
+ --inline a self-contained deck: runtime and themes embedded, so it
593
+ opens from disk without decklight — pinned to this version,
594
+ ~650 KB before the first slide. The default is slides plus
595
+ a JSON configuration block and no runtime in the file:
596
+ decklight serves the installed runtime into it, and
597
+ \`decklight bundle\` embeds it when the deck is handed over.
598
+ --themes <sel> with --inline, which themes to embed:
490
599
  all every shipped theme (default)
491
600
  name,name,… an explicit list (aurora stays active when
492
601
  included, else the first listed)
602
+ --design-system <ref>
603
+ start the deck on a design system a registered marketplace
604
+ offers (name or name@marketplace, read from the cached
605
+ catalogs: nothing is fetched). The deck references it and
606
+ takes what \`decklight design-system add <ref> <deck> --apply\`
607
+ gives: its recommended themes and fonts, its theme and font,
608
+ and a title slide on its first template with a heading slot.
609
+ Refused with --inline: a file opened from disk has no server
610
+ to link a design system (\`decklight bundle\` embeds one).
611
+ (a cached catalog lists one + no flag: init ASKS on a TTY,
612
+ and off a terminal names them in one line)
613
+ --no-design-system
614
+ decklight's own themes; asks nothing about a design system
493
615
  --git create a git repository (with a starter .gitignore) and
494
616
  commit everything init wrote
495
617
  (outside a repo + no flag: init ASKS on a TTY)
496
618
  --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)
619
+ --remote <url> add it as origin to the repository init creates, and push
620
+ (without it, a terminal run offers a private GitHub
621
+ repository when gh is signed in, or asks for a URL)
622
+ --no-remote create the repository, and ask nothing about a remote
623
+ --no-open start the deck without opening the browser. Once the deck
624
+ is written, init opens it: the default deck in write mode
625
+ (live reload, edits from the browser, an AI agent on A), a
626
+ self-contained --inline deck as a file in your browser.
627
+ --no-open starts the write-mode server and leaves the
628
+ browser to you. Off a terminal init only prints the
629
+ command (a server nobody can stop is never started), and
630
+ opens a self-contained deck's file only when --open is
631
+ typed.
499
632
  --force overwrite an existing deck file (default: refuses)
500
633
  --no-skill skip the agent skill entirely (project and global), and the
501
634
  where-should-it-go question with it
@@ -519,27 +652,37 @@ unless --no-skill is given. The deck file is only touched with --force.
519
652
  return 0;
520
653
  }
521
654
 
522
- let title = null, outFile = 'deck.html', dir = '.', force = false, themesSel = 'all', openAfter = false;
523
- let from = null;
655
+ let title = null, outFile = 'deck.html', dir = '.', force = false, themesSel = 'all', inline = false;
524
656
  const args = [...argv];
525
657
  for (let i = 0; i < args.length; i++) {
526
658
  const a = args[i];
527
659
  if (a === '-o') outFile = args[++i];
528
660
  else if (a === '--dir') dir = args[++i];
529
- else if (a === '--from') from = args[++i];
530
661
  else if (a === '--themes') themesSel = args[++i];
662
+ else if (a === '--inline') inline = true;
531
663
  else if (a === '--force') force = true;
532
- else if (a === '--open') openAfter = true;
664
+ else if (a === '--open' || a === '--no-open') ; // the handoff, below (--open is the default)
533
665
  else if (a === '--no-skill' || a === '--global-skill') ; // consumed by planSkill below
534
666
  else if (a === '--git' || a === '--no-git') ; // consumed by planGit below
535
667
  else if (a === '--remote') i++; // consumed by planRemote below
536
668
  else if (a === '--no-remote') ; // likewise
669
+ else if (a === '--design-system') i++; // consumed by planDesignSystem below
670
+ else if (a === '--no-design-system') ; // likewise
537
671
  else if (!a.startsWith('-')) title = title ?? a;
538
672
  else fail(`unknown argument: ${a}`);
539
673
  }
540
674
  if (argv.includes('--no-skill') && argv.includes('--global-skill')) {
541
675
  fail('--no-skill and --global-skill are mutually exclusive');
542
676
  }
677
+ // a refusal, or a --design-system no cached catalog has, fails here: before
678
+ // a question is asked or a file written
679
+ const home = configHome(env);
680
+ let ds = planDesignSystem({ args: argv, inline });
681
+ if (ds.action === 'refuse') fail(ds.why);
682
+ let dsRef = null;
683
+ if (ds.action === 'use') {
684
+ try { dsRef = await resolveDesignSystemFlag(ds.ref, home); } catch (e) { fail(e.message); }
685
+ }
543
686
 
544
687
  // ONE readline interface for every question this run asks (title, git,
545
688
  // handoff). Lines arriving BETWEEN questions (answers typed ahead) are
@@ -551,20 +694,22 @@ unless --no-skill is given. The deck file is only touched with --force.
551
694
  rl?.on('line', (l) => typedAhead.push(l)); // only fires with no question pending
552
695
  let stdinGone = false;
553
696
  rl?.once('close', () => { stdinGone = true; });
554
- const question = (q) => {
697
+ // `{ answer, eof }`: an empty answer is Enter, unless the input has ended
698
+ const ask = (q) => {
555
699
  if (typedAhead.length) {
556
700
  const answer = typedAhead.shift();
557
701
  process.stdout.write(q + answer + '\n'); // the transcript still records the decision
558
- return Promise.resolve(answer);
702
+ return Promise.resolve({ answer, eof: false });
559
703
  }
560
- if (!rl || stdinGone) return Promise.resolve('');
704
+ if (!rl || stdinGone) return Promise.resolve({ answer: '', eof: true });
561
705
  // rl.question's promise never settles when the input ends mid-question
562
706
  // (observed on Node 20), so the close event doubles as the empty answer
563
707
  return new Promise((res) => {
564
- rl.once('close', () => res(''));
565
- rl.question(q).then(res, () => res(''));
708
+ rl.once('close', () => res({ answer: '', eof: true }));
709
+ rl.question(q).then((answer) => res({ answer, eof: false }), () => res({ answer: '', eof: true }));
566
710
  });
567
711
  };
712
+ const question = async (q) => (await ask(q)).answer;
568
713
  // `defaultYes` is what a bare Enter means. It is a parameter rather than a
569
714
  // constant because the remote question flips it: for a directory decklight
570
715
  // scaffolded the answer is almost certainly yes, and for one that already
@@ -576,15 +721,8 @@ unless --no-skill is given. The deck file is only touched with --force.
576
721
  return defaultYes ? !/^n/i.test(a) : /^y/i.test(a);
577
722
  };
578
723
 
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
724
  title = await resolveTitle(title, { isTTY: tty, ask: question });
587
- const themeNames = resolveThemes(from ? 'all' : themesSel);
725
+ const themeNames = resolveThemes(themesSel);
588
726
  const activeTheme = themeNames.includes(STARTER_THEME) ? STARTER_THEME : themeNames[0];
589
727
 
590
728
  const root = path.resolve(dir);
@@ -608,24 +746,52 @@ unless --no-skill is given. The deck file is only touched with --force.
608
746
  }
609
747
  fail(`${rel} already exists — pass --force to overwrite`);
610
748
  }
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
749
+ // ── the design system: asked right after the title, wired before the write
750
+ const deckRel = path.relative('.', deckPath) || outFile;
751
+ if (ds.action === 'skip' && !inline && !argv.includes('--no-design-system')) {
752
+ ds = planDesignSystem({ args: argv, tty, inline, ...(await availableDesignSystems(home)) });
753
+ }
754
+ if (ds.action === 'ask') {
755
+ const { lines, prompt } = designSystemQuestion(ds, { color });
756
+ for (const l of lines) process.stdout.write(`${l}\n`);
757
+ for (;;) {
758
+ const { answer, eof } = await ask(prompt);
759
+ const r = pickDesignSystem(answer, ds, { eof });
760
+ if (r.again) continue;
761
+ dsRef = r.pick?.qualified ?? null;
762
+ break;
763
+ }
764
+ }
765
+ const plainNote = 'slides and a config block, no runtime in the file — decklight bundle embeds it to send';
766
+ let body = starterDeck(title, themeNames, activeTheme, { inline });
767
+ let themeNote = !inline ? `theme: ${activeTheme} · ${plainNote}`
768
+ : themeNames.length === 1
624
769
  ? `theme: ${themeNames[0]}`
625
770
  : `${themeNames.length} themes, ${activeTheme} active`;
771
+ let wired = null, dsNote = null;
772
+ if (dsRef) {
773
+ // a failure here costs a note and a plain deck, never the scaffold
774
+ try {
775
+ wired = await wireDesignSystem((titleSlide) => starterDeck(title, themeNames, activeTheme, { titleSlide }),
776
+ dsRef, { home, titleHtml: escapeHtml(title) });
777
+ body = wired.html;
778
+ themeNote = `${wired.label} · ${plainNote}`;
779
+ } catch (e) {
780
+ dsNote = ` design system: ${dsRef} not wired in — ${String(e?.message ?? e).replace(/\s+/g, ' ')}; the deck starts plain`
781
+ + ` (decklight design-system add ${dsRef} ${deckRel} --apply retries)`;
782
+ }
626
783
  }
627
784
  fs.writeFileSync(deckPath, body);
628
- note(`created ${path.relative('.', deckPath) || outFile} (${themeNote})`);
785
+ note(`created ${deckRel} (${themeNote})`);
786
+ if (dsNote) note(dsNote);
787
+ if (ds.action === 'hint') note(designSystemHint(ds.systems));
788
+ if (wired) {
789
+ for (const l of wired.warnings) note(l);
790
+ try {
791
+ const { recordInstall } = await import('./marketplace.mjs');
792
+ for (const inst of wired.installs) recordInstall(inst, home);
793
+ } catch (e) { note(` design system: the deck uses it, but installed.json could not record it — ${oneline(e)}`); }
794
+ }
629
795
 
630
796
  // ── the skill — project scope by default, global as a proposition ────────
631
797
  let skill = planSkill({ args: argv, tty }).action;
@@ -677,33 +843,17 @@ unless --no-skill is given. The deck file is only touched with --force.
677
843
  const plan = planGit({ args: argv, tty, inRepo: inGitRepo(root) });
678
844
  let { action } = plan;
679
845
  if (action === 'ask') {
680
- action = (await askYes(' create a git repository so your edits are auto-committed? [Y/n] '))
846
+ action = (await askYes(' create a git repository so every version of the deck is kept? [Y/n] '))
681
847
  ? 'create' : 'skip';
682
848
  }
683
849
  if (action === 'create') {
684
850
  note(initRepo(root));
685
851
  // Stated, not asked: the mode is already the default, so a fifth prompt
686
852
  // 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
- }
853
+ note(' your edits are snapshotted as you go and committed when you press K;'
854
+ + " an agent's edit commits itself, with its own message (--git-mode timer for a plain cadence)");
705
855
  }
706
- else if (action === 'hint') note(' git: no repository here — pass --git to create one and auto-commit the deck');
856
+ else if (action === 'hint') note(' git: no repository here — pass --git to create one and keep every version of the deck');
707
857
 
708
858
  // ── the remote offer — the deck exists nowhere else until this happens ───
709
859
  // ONLY for a repository decklight just created. A repo that was already here
@@ -735,17 +885,33 @@ unless --no-skill is given. The deck file is only touched with --force.
735
885
 
736
886
  process.stdout.write(epilogue({ deckPath, tty: !!process.stdout.isTTY, noColor: !!process.env.NO_COLOR }));
737
887
 
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.
888
+ // ── the handoff: the deck opens ───────────────────────────────────────────
889
+ // The epilogue names the command, and on a terminal init runs it, because
890
+ // the deck opened as a FILE is one where E, A and L all answer "needs
891
+ // decklight <deck>": the newcomer's first three keystrokes would hit the one
892
+ // command they have not seen yet. `--no-open` keeps the browser closed and
893
+ // nothing else: the server still starts. A run that is not on a terminal —
894
+ // a script, an agent, CI — never has a server started for it, since nobody
895
+ // is there to stop one; the epilogue is the whole handoff there. Everything
896
+ // init printed stays on screen above the deck's banner.
748
897
  rl?.close();
898
+ const noOpen = argv.includes('--no-open');
899
+ // A self-contained --inline deck IS the
900
+ // presentation: there is no server to hand it to, so it opens as a file —
901
+ // last of the writes, so every "created/wrote" line is on screen before
902
+ // the browser steals focus. Off a terminal only a typed --open opens it:
903
+ // a browser nobody asked for is not what a script wants.
904
+ if (inline) {
905
+ if (!noOpen && (tty || argv.includes('--open'))) await openDeck(deckPath);
906
+ return undefined;
907
+ }
908
+ if (!tty) return undefined;
909
+ const rel = path.relative(root, deckPath);
910
+ const cli = fileURLToPath(new URL('./decklight.mjs', import.meta.url));
911
+ // the banner has been printed once, by this run; the child is the same version
912
+ const r = spawnSync(process.execPath, [cli, ...handoffArgs({ rel, argv, gitPlan: plan.action, gitAction: action, noOpen })],
913
+ { stdio: 'inherit', cwd: root, env: { ...process.env, DECKLIGHT_BANNER: '1' } });
914
+ return r.status ?? 0;
749
915
  }
750
916
 
751
917
  if (isMain(import.meta.url)) process.exitCode = await runMain('init', initMain);