decklight 0.9.0 → 0.11.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/NOTICE +2 -0
  2. package/PLATFORM.md +61 -3
  3. package/README.md +58 -28
  4. package/SPEC.md +1326 -85
  5. package/cli/agent-review.mjs +5 -4
  6. package/cli/agents.mjs +148 -18
  7. package/cli/bundle-audio.mjs +10 -3
  8. package/cli/bundle-module.mjs +95 -0
  9. package/cli/bundle.mjs +125 -7
  10. package/cli/cast.mjs +86 -19
  11. package/cli/check-fixes.mjs +194 -0
  12. package/cli/check-watch.mjs +151 -0
  13. package/cli/check.mjs +491 -75
  14. package/cli/code-editor.mjs +287 -0
  15. package/cli/commands.mjs +13 -2
  16. package/cli/commit-flow.mjs +7 -3
  17. package/cli/commit-message.mjs +35 -8
  18. package/cli/commit-split.mjs +125 -25
  19. package/cli/deck-refs.mjs +8 -3
  20. package/cli/decklight.mjs +11 -1
  21. package/cli/design-system-edit.mjs +37 -1
  22. package/cli/design-system-refs.mjs +263 -6
  23. package/cli/design-system.mjs +82 -14
  24. package/cli/edit-address.mjs +184 -0
  25. package/cli/edit-git.mjs +23 -6
  26. package/cli/edit-handover.mjs +257 -40
  27. package/cli/edit-look.mjs +293 -6
  28. package/cli/edit-open.mjs +143 -0
  29. package/cli/edit-slides.mjs +1043 -67
  30. package/cli/edit-translate.mjs +243 -0
  31. package/cli/edit.mjs +3680 -319
  32. package/cli/editor-support.mjs +286 -0
  33. package/cli/enhance.mjs +157 -27
  34. package/cli/find-replace.mjs +142 -0
  35. package/cli/fix-review.mjs +368 -0
  36. package/cli/git.mjs +13 -0
  37. package/cli/init.mjs +101 -22
  38. package/cli/keep-awake.mjs +68 -0
  39. package/cli/marketplace-autocheck.mjs +200 -0
  40. package/cli/marketplace.mjs +250 -13
  41. package/cli/migrate-writing.mjs +214 -0
  42. package/cli/narrate.mjs +121 -5
  43. package/cli/open.mjs +53 -15
  44. package/cli/outside-edit.mjs +257 -0
  45. package/cli/paste.mjs +92 -0
  46. package/cli/pdf.mjs +88 -10
  47. package/cli/pptx-export.mjs +10 -5
  48. package/cli/publish.mjs +24 -3
  49. package/cli/record.mjs +86 -15
  50. package/cli/remote.mjs +32 -6
  51. package/cli/rewrite.mjs +265 -0
  52. package/cli/runtime-link.mjs +218 -17
  53. package/cli/serve.mjs +9 -6
  54. package/cli/setup.mjs +2 -2
  55. package/cli/skill-content.mjs +251 -10
  56. package/cli/skills/slide-writing.md +333 -0
  57. package/cli/skills/voiceover.md +423 -0
  58. package/cli/skills.mjs +282 -15
  59. package/cli/starter-full.mjs +353 -0
  60. package/cli/supervise.mjs +14 -0
  61. package/cli/theme-refs.mjs +14 -2
  62. package/cli/theme.mjs +3 -2
  63. package/cli/translate-core.mjs +466 -0
  64. package/cli/translate-files.mjs +149 -0
  65. package/cli/translate.mjs +458 -0
  66. package/cli/units.mjs +75 -7
  67. package/cli/util.mjs +25 -0
  68. package/cli/vocabulary-docs.mjs +138 -0
  69. package/dist/decklight.css +2506 -113
  70. package/dist/decklight.js +385 -175
  71. package/dist/decklight.js.map +4 -4
  72. package/docs/GLOSSARY.md +9 -2
  73. package/docs/WRITING_RESEARCH.md +327 -0
  74. package/package.json +5 -3
  75. package/themes/coastal.css +3 -0
  76. package/themes/metropolis.css +2 -0
  77. package/themes/reveal-blood.css +3 -0
  78. package/themes/reveal-league.css +2 -0
  79. package/themes/reveal-moon.css +2 -0
  80. package/themes/reveal-serif.css +1 -0
  81. package/themes/reveal-sky.css +1 -0
  82. package/themes/reveal-solarized.css +4 -0
  83. package/tools/brand-palette.mjs +6 -1
  84. package/tools/build-groups.mjs +28 -8
  85. package/tools/cdp.mjs +176 -0
  86. package/tools/chart-spec.mjs +242 -0
  87. package/tools/click-match.mjs +70 -0
  88. package/tools/code-options.mjs +174 -0
  89. package/tools/conversation.mjs +49 -0
  90. package/tools/deck-family.mjs +101 -0
  91. package/tools/deck-html.mjs +212 -15
  92. package/tools/design-system-format.mjs +40 -1
  93. package/tools/design-system-migrations.mjs +207 -0
  94. package/tools/diagram-shapes.mjs +221 -0
  95. package/tools/elevenlabs-tts.mjs +62 -53
  96. package/tools/exec.mjs +10 -2
  97. package/tools/face-clip.mjs +96 -0
  98. package/tools/face-layout.mjs +94 -0
  99. package/tools/gemini-tts.mjs +1 -1
  100. package/tools/invisible-in-print.mjs +27 -0
  101. package/tools/lipsync-auto.mjs +197 -0
  102. package/tools/lipsync-config.mjs +16 -0
  103. package/tools/lipsync-engines.mjs +22 -4
  104. package/tools/lipsync-server.mjs +8 -5
  105. package/tools/lipsync.mjs +122 -30
  106. package/tools/local-voice.mjs +1 -1
  107. package/tools/mouth-file.mjs +26 -0
  108. package/tools/mouth.mjs +320 -0
  109. package/tools/narration-manifest.mjs +100 -6
  110. package/tools/narration-synth.mjs +96 -76
  111. package/tools/recording-impact.mjs +16 -1
  112. package/tools/sentences.mjs +7 -1
  113. package/tools/site-clip.mjs +114 -0
  114. package/tools/starters.mjs +402 -0
  115. package/tools/steps.mjs +118 -0
  116. package/tools/take-check.mjs +146 -0
  117. package/tools/template-theme.mjs +3 -1
  118. package/tools/test-impact.mjs +36 -12
  119. package/tools/theme-check.mjs +196 -1
  120. package/tools/tone-cue.mjs +108 -0
  121. package/tools/tts-cache.mjs +9 -3
  122. package/tools/tts-engines.mjs +100 -11
  123. package/tools/video-cache.mjs +93 -0
  124. package/tools/video-live.mjs +349 -0
  125. package/tools/video-options.mjs +11 -0
  126. package/tools/video.mjs +825 -117
  127. package/tools/viseme-fit.mjs +27 -0
  128. package/tools/viseme-match.mjs +77 -0
  129. package/tools/vocabulary.mjs +397 -0
  130. package/tools/voice-renumber.mjs +605 -0
  131. package/tools/voiceover-server.mjs +42 -11
  132. package/tools/voiceover.mjs +48 -20
  133. package/dist/build-info.json +0 -1
@@ -0,0 +1,184 @@
1
+ // Copyright 2026 Gilles Philippart
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Where a write-mode edit lands in the deck FILE, and how one attribute or
5
+ // one node is changed there (PRESENTING_EDITING). Every element transform in
6
+ // cli/edit.mjs addresses its target the same way, so the way lives here once:
7
+ //
8
+ // a slide's top-level element is its raw index among the `<section>`'s
9
+ // direct children (title included, sectionChildRanges);
10
+ // a node inside one is a `path` of element-child indices below it, counted
11
+ // over the FILE's elements (the live DOM is not the file: the engine adds
12
+ // nodes of its own), plus the `tag` the page saw there. A path the file
13
+ // does not have, or one that lands on another tag, is STALE (a 409), never
14
+ // a guess.
15
+ //
16
+ // Every change is textual: one open tag's attribute rewritten where it
17
+ // stands, or one node's text spliced, so the author's bytes and indentation
18
+ // around it survive.
19
+
20
+ import { locateSlide, sectionChildRanges, elementChildRanges, splitOpenTag } from '../tools/deck-html.mjs';
21
+ import { escapeHtml } from '../tools/escape.mjs';
22
+
23
+ /** The page and the file disagree about what is where: a 409, not a bad request. */
24
+ export const stale = (message) => Object.assign(new Error(message), { code: 'STALE' });
25
+
26
+ /** `path` if it is one (`nested`: below the element, never the element itself), or a 400. */
27
+ export function checkPath(path, { nested = false } = {}) {
28
+ if (!Array.isArray(path) || (nested && !path.length) || path.length > 16 || path.some((n) => !Number.isInteger(n) || n < 0)) throw new Error('bad path');
29
+ return path;
30
+ }
31
+
32
+ /** Look up element `index` (raw child position) on slide `slide`, or throw. */
33
+ export function locateElement(html, slide, index) {
34
+ const { parts, idx } = locateSlide(html, slide);
35
+ const seg = parts[idx];
36
+ const ranges = sectionChildRanges(seg);
37
+ const r = ranges[index];
38
+ if (!r) throw new Error(`slide ${slide}: no element at index ${index} (has ${ranges.length})`);
39
+ return { parts, idx, seg, r };
40
+ }
41
+
42
+ const tagAt = (s) => /^<([a-zA-Z][\w:-]*)/.exec(s)?.[1]?.toLowerCase() ?? null;
43
+
44
+ /**
45
+ * The node at `path` below `el` (a slide element's source): its offsets in
46
+ * `el`, its tag, and the nodes on the way down (`el` first, its parent last),
47
+ * so a caller can ask whether it sits in a diagram and what holds it. A path
48
+ * the file does not have, or one that lands on another tag than the page saw,
49
+ * is stale.
50
+ */
51
+ export function nodeAt(el, path, { slide, index, tag = null }) {
52
+ checkPath(path);
53
+ let start = 0; let end = el.length;
54
+ const chain = [];
55
+ for (const n of path) {
56
+ chain.push({ start, end, tag: tagAt(el.slice(start, end)) });
57
+ const kid = elementChildRanges(el.slice(start, end))[n];
58
+ if (!kid) throw stale(`slide ${slide} #${index}: the file has no element at ${path.join('.')} — the engine drew this one, or the deck changed; reload and try again`);
59
+ end = start + kid.end; start += kid.start;
60
+ }
61
+ const found = tagAt(el.slice(start, end));
62
+ if (tag && found !== String(tag).toLowerCase()) {
63
+ throw stale(`slide ${slide} #${index}: the page found <${tag}> at ${path.join('.') || 'the element'}, the file has <${found}> — reload and try again`);
64
+ }
65
+ const svgAt = chain.map((c) => c.tag).lastIndexOf('svg');
66
+ return { start, end, found, chain, parent: chain.at(-1) ?? null, svg: svgAt < 0 ? null : chain[svgAt], inSvg: svgAt >= 0 };
67
+ }
68
+
69
+ /**
70
+ * Slide N's element `index`, open for an edit: `el` is its source, changed
71
+ * through `splice` and `edit`, and `html()` is the deck with it put back.
72
+ *
73
+ * at(path, tag) the node there (nodeAt), offsets into `el` as it is now
74
+ * src(at) that node's source
75
+ * splice(s, e, text) `el` with [s, e) replaced
76
+ * edit(path, tag, fn) that node's open tag made `fn(attrs, at)`, the rest kept
77
+ * lead(at) what stands before the node on its line, read in the
78
+ * slide (the node may be the element itself): only
79
+ * spaces when it begins the line
80
+ */
81
+ export function openElement(html, slide, index) {
82
+ const { parts, idx, seg, r } = locateElement(html, slide, index);
83
+ const e = {
84
+ el: seg.slice(r.start, r.end),
85
+ at: (path, tag = null) => nodeAt(e.el, path, { slide, index, tag }),
86
+ src: (at) => e.el.slice(at.start, at.end),
87
+ splice(start, end, text) { e.el = e.el.slice(0, start) + text + e.el.slice(end); },
88
+ edit(path, tag, fn) {
89
+ const at = e.at(path, tag);
90
+ const { attrs, close, rest } = splitOpenTag(e.src(at));
91
+ e.splice(at.start, at.end, fn(attrs, at) + close + rest);
92
+ return at;
93
+ },
94
+ lead(at) {
95
+ const abs = r.start + at.start;
96
+ return seg.slice(seg.lastIndexOf('\n', abs - 1) + 1, abs);
97
+ },
98
+ html() { parts[idx] = seg.slice(0, r.start) + e.el + seg.slice(r.end); return parts.join(''); },
99
+ };
100
+ return e;
101
+ }
102
+
103
+ // ── one attribute on an open tag ───────────────────────────────────────────
104
+
105
+ /** The text a run of markup reads as: the entities a label or an attribute is likely to carry, decoded. */
106
+ export const decodeText = (s) => String(s).replace(/&(#x[0-9a-f]+|#\d+|amp|lt|gt|quot|apos|nbsp);/gi, (m, e) => {
107
+ const k = e.toLowerCase();
108
+ if (k[0] === '#') return String.fromCodePoint(k[1] === 'x' ? parseInt(k.slice(2), 16) : parseInt(k.slice(1), 10));
109
+ return { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' }[k];
110
+ });
111
+
112
+ /** The attributes of an open tag's text (`<rect x="1" …`, no `>`), each with where it stands, so one can be changed in place. */
113
+ export function attrList(attrs) {
114
+ const out = [];
115
+ const head = /^<[a-zA-Z][\w:-]*/.exec(attrs);
116
+ const re = /(\s+)([^\s=/>"']+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s>"']+))?/y;
117
+ re.lastIndex = head ? head[0].length : 0;
118
+ for (let m = re.exec(attrs); m; m = re.exec(attrs)) {
119
+ const raw = m[3] ?? null;
120
+ out.push({ name: m[2].toLowerCase(), written: m[2], lead: m[1], start: m.index, end: re.lastIndex, raw,
121
+ value: raw === null ? '' : /^["']/.test(raw) ? raw.slice(1, -1) : raw });
122
+ }
123
+ return out;
124
+ }
125
+
126
+ /** What attribute `name` says on an open tag's text, its entities read (`a&amp;b.png` is `a&b.png`), or null. */
127
+ export function attrOf(attrs, name) {
128
+ const a = attrList(attrs).find((x) => x.name === name);
129
+ return a ? decodeText(a.value) : null;
130
+ }
131
+
132
+ /**
133
+ * An open tag's text with attribute `name` set to `value` where it stands (its
134
+ * quote and the space before it kept), or added last; null takes it off. The
135
+ * value is escaped the one way every attribute is (escapeHtml: `&`, `<`, `>`
136
+ * and `"`; a `'` too inside single quotes), so what attrOf reads back is what
137
+ * was set: alt text with an ampersand, a name, a number alike. `true` writes
138
+ * the attribute bare (`data-build-stay`, `controls`), its value dropped if it
139
+ * had one, its spelling and the space before it kept.
140
+ */
141
+ export function withAttr(attrs, name, value) {
142
+ const a = attrList(attrs).find((x) => x.name === name);
143
+ if (value === null) return a ? attrs.slice(0, a.start) + attrs.slice(a.end) : attrs;
144
+ if (value === true) {
145
+ if (a) return attrs.slice(0, a.start) + `${a.lead}${a.written}` + attrs.slice(a.end);
146
+ const tail = /\s*$/.exec(attrs)[0];
147
+ return `${attrs.slice(0, attrs.length - tail.length)} ${name}${tail}`;
148
+ }
149
+ const q = a?.raw?.[0] === "'" ? "'" : '"';
150
+ let v = escapeHtml(value);
151
+ if (q === "'") v = v.replace(/'/g, '&#39;');
152
+ if (a) return attrs.slice(0, a.start) + `${a.lead}${a.written}=${q}${v}${q}` + attrs.slice(a.end);
153
+ const tail = /\s*$/.exec(attrs)[0];
154
+ return `${attrs.slice(0, attrs.length - tail.length)} ${name}="${v}"${tail}`;
155
+ }
156
+
157
+ /** `style` text with `prop` set to `value` (null: taken off) — its old declaration replaced, the rest kept in order. */
158
+ export function withStyleProp(style, prop, value) {
159
+ const kept = String(style ?? '').split(';').map((d) => d.trim()).filter(Boolean)
160
+ .filter((d) => d.slice(0, d.indexOf(':')).trim().toLowerCase() !== prop);
161
+ return (value === null ? kept : [...kept, `${prop}: ${value}`]).join('; ');
162
+ }
163
+
164
+ /** An open tag's text with one declaration of its `style` set (null: taken off), and a `style` left empty gone. */
165
+ export const withStyle = (attrs, prop, value) => withAttr(attrs, 'style', withStyleProp(attrOf(attrs, 'style'), prop, value) || null);
166
+
167
+ // ── one node out ────────────────────────────────────────────────────────────
168
+
169
+ /**
170
+ * `text` without the nodes at `ranges` (`[[start, end]…]`): each with its line
171
+ * when it stood alone on one, so the file is left without a blank one. The
172
+ * last goes first, so the offsets before it hold.
173
+ */
174
+ export function withoutNodes(text, ranges) {
175
+ let out = text;
176
+ for (let [s, e] of [...ranges].sort((a, b) => b[0] - a[0])) {
177
+ const lineStart = out.lastIndexOf('\n', s - 1) + 1;
178
+ const nl = out.indexOf('\n', e);
179
+ const lineEnd = nl < 0 ? out.length : nl;
180
+ if (/^[ \t]*$/.test(out.slice(lineStart, s)) && /^[ \t]*$/.test(out.slice(e, lineEnd)) && nl >= 0) { s = lineStart; e = nl + 1; }
181
+ out = out.slice(0, s) + out.slice(e);
182
+ }
183
+ return out;
184
+ }
package/cli/edit-git.mjs CHANGED
@@ -57,6 +57,7 @@ export function registerGitRoutes(routes, {
57
57
  readDeck, history, broadcast = () => {}, deckPath, deckRel, root,
58
58
  gitOn, agentPref, subjectsOff, describer,
59
59
  commitState, measureDirty, resetEpisode, alsoNow, alsoRels, attrRel, pendingAttr, clearPendingAttr, dismissNag,
60
+ followOutside = () => null,
60
61
  }) {
61
62
  // ── committing on the author's word (SPEC PRESENTING) ─────────────────
62
63
  // What is uncommitted, right now. The overlay opens on this rather than
@@ -88,14 +89,23 @@ export function registerGitRoutes(routes, {
88
89
  // `describeCommit`'s amend is for messages decklight authored, and this
89
90
  // one has an author.
90
91
  function commitRoute({ body, json }) {
92
+ // An outside agent commits its own edit here, sooner than the file watch
93
+ // may have looked: the voice folders follow its slides first (#954), so
94
+ // the commit is of a deck whose recordings are where its slides are.
95
+ followOutside();
91
96
  if (!gitOn()) return json(409, { ok: false, error: 'this session is not committing — open the deck with --git' });
92
97
  let msg = '';
93
98
  try { msg = String(JSON.parse(body || '{}').message ?? '').trim(); } catch { /* below */ }
94
99
  if (!msg) return json(400, { ok: false, error: 'a commit needs a message' });
95
- const subject = commitSubject(msg, `decklight: autosave ${basename(deckPath)}`);
100
+ // A blank line starts a BODY, as git writes one: a reviewed fix drafts
101
+ // the slides it rejected there (#907). Without one the message is a
102
+ // subject, its lines run together, as it always was.
103
+ const cut = msg.search(/\n[ \t]*\n/);
104
+ const subject = commitSubject(cut < 0 ? msg : msg.slice(0, cut), `decklight: autosave ${basename(deckPath)}`);
105
+ const text = cut < 0 ? '' : msg.slice(cut).trim().split('\n').map((l) => l.trimEnd()).join('\n').slice(0, 4000);
96
106
  // gitAutocommit reports false for "nothing to commit", which is not an
97
107
  // error: it is the answer to pressing K twice.
98
- const made = gitAutocommit(deckPath, root, subject, alsoNow());
108
+ const made = gitAutocommit(deckPath, root, text ? `${subject}\n\n${text}` : subject, alsoNow());
99
109
  if (!made) return json(200, { ok: true, committed: false, ...commitState() });
100
110
  clearPendingAttr();
101
111
  resetEpisode();
@@ -128,7 +138,7 @@ export function registerGitRoutes(routes, {
128
138
  return json(200, { ok: true, subject: null });
129
139
  }
130
140
 
131
- // "write them for me": the uncommitted work cut into the commits an agent
141
+ // "write it for me": the uncommitted work cut into the commits an agent
132
142
  // proposes (cli/commit-split.mjs). The plan carries `base`, the fingerprint
133
143
  // of the work it was made on, which the split route checks before it
134
144
  // commits anything. Asked only on the click, like the one-line subject.
@@ -137,15 +147,22 @@ export function registerGitRoutes(routes, {
137
147
  if (subjectsOff) {
138
148
  return json(403, { ok: false, error: 'commit subjects are off in this session — it was started with --no-commit-messages' });
139
149
  }
140
- const { work, commits } = await planWorking({
150
+ const { work, commits, unread } = await planWorking({
141
151
  cwd: root, deckPath, deckRel, also: alsoRels(), agent: agentPref(),
152
+ template: `decklight: autosave ${basename(deckPath)}`,
142
153
  });
143
154
  if (!work) return json(409, { ok: false, code: 'FIRST', error: 'the first commit is one commit — write its message' });
144
155
  if (!commits) return json(200, { ok: true, base: work.base, units: [], commits: [] });
145
156
  if (!describer() && work.units.some((u) => u.file === deckRel)) {
146
- return json(409, { ok: false, error: 'no agent is installed on this machine to write them — decklight doctor lists the ones it can use' });
157
+ return json(409, { ok: false, error: 'no agent is installed on this machine to write one — decklight doctor lists the ones it can use' });
147
158
  }
148
- return json(200, { ok: true, base: work.base, units: work.units.map(unitSummary), commits });
159
+ // `unread`: the agent was asked, and neither the plan nor the one-line
160
+ // subject could be read from what it said — not the same as nothing to describe
161
+ if (unread) console.log(` git: couldn't read the agent's plan — ${JSON.stringify(unread.answer.slice(0, 200))}`);
162
+ return json(200, {
163
+ ok: true, base: work.base, units: work.units.map(unitSummary), commits,
164
+ ...(unread ? { unread: true, answer: unread.answer } : {}),
165
+ });
149
166
  }
150
167
 
151
168
  // The proposed commits, as the author left them: each subject theirs now,