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.
- package/NOTICE +2 -0
- package/PLATFORM.md +61 -3
- package/README.md +58 -28
- package/SPEC.md +1326 -85
- package/cli/agent-review.mjs +5 -4
- package/cli/agents.mjs +148 -18
- package/cli/bundle-audio.mjs +10 -3
- package/cli/bundle-module.mjs +95 -0
- package/cli/bundle.mjs +125 -7
- package/cli/cast.mjs +86 -19
- package/cli/check-fixes.mjs +194 -0
- package/cli/check-watch.mjs +151 -0
- package/cli/check.mjs +491 -75
- package/cli/code-editor.mjs +287 -0
- package/cli/commands.mjs +13 -2
- package/cli/commit-flow.mjs +7 -3
- package/cli/commit-message.mjs +35 -8
- package/cli/commit-split.mjs +125 -25
- package/cli/deck-refs.mjs +8 -3
- package/cli/decklight.mjs +11 -1
- package/cli/design-system-edit.mjs +37 -1
- package/cli/design-system-refs.mjs +263 -6
- package/cli/design-system.mjs +82 -14
- package/cli/edit-address.mjs +184 -0
- package/cli/edit-git.mjs +23 -6
- package/cli/edit-handover.mjs +257 -40
- package/cli/edit-look.mjs +293 -6
- package/cli/edit-open.mjs +143 -0
- package/cli/edit-slides.mjs +1043 -67
- package/cli/edit-translate.mjs +243 -0
- package/cli/edit.mjs +3680 -319
- package/cli/editor-support.mjs +286 -0
- package/cli/enhance.mjs +157 -27
- package/cli/find-replace.mjs +142 -0
- package/cli/fix-review.mjs +368 -0
- package/cli/git.mjs +13 -0
- package/cli/init.mjs +101 -22
- package/cli/keep-awake.mjs +68 -0
- package/cli/marketplace-autocheck.mjs +200 -0
- package/cli/marketplace.mjs +250 -13
- package/cli/migrate-writing.mjs +214 -0
- package/cli/narrate.mjs +121 -5
- package/cli/open.mjs +53 -15
- package/cli/outside-edit.mjs +257 -0
- package/cli/paste.mjs +92 -0
- package/cli/pdf.mjs +88 -10
- package/cli/pptx-export.mjs +10 -5
- package/cli/publish.mjs +24 -3
- package/cli/record.mjs +86 -15
- package/cli/remote.mjs +32 -6
- package/cli/rewrite.mjs +265 -0
- package/cli/runtime-link.mjs +218 -17
- package/cli/serve.mjs +9 -6
- package/cli/setup.mjs +2 -2
- package/cli/skill-content.mjs +251 -10
- package/cli/skills/slide-writing.md +333 -0
- package/cli/skills/voiceover.md +423 -0
- package/cli/skills.mjs +282 -15
- package/cli/starter-full.mjs +353 -0
- package/cli/supervise.mjs +14 -0
- package/cli/theme-refs.mjs +14 -2
- package/cli/theme.mjs +3 -2
- package/cli/translate-core.mjs +466 -0
- package/cli/translate-files.mjs +149 -0
- package/cli/translate.mjs +458 -0
- package/cli/units.mjs +75 -7
- package/cli/util.mjs +25 -0
- package/cli/vocabulary-docs.mjs +138 -0
- package/dist/decklight.css +2506 -113
- package/dist/decklight.js +385 -175
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +9 -2
- package/docs/WRITING_RESEARCH.md +327 -0
- package/package.json +5 -3
- package/themes/coastal.css +3 -0
- package/themes/metropolis.css +2 -0
- package/themes/reveal-blood.css +3 -0
- package/themes/reveal-league.css +2 -0
- package/themes/reveal-moon.css +2 -0
- package/themes/reveal-serif.css +1 -0
- package/themes/reveal-sky.css +1 -0
- package/themes/reveal-solarized.css +4 -0
- package/tools/brand-palette.mjs +6 -1
- package/tools/build-groups.mjs +28 -8
- package/tools/cdp.mjs +176 -0
- package/tools/chart-spec.mjs +242 -0
- package/tools/click-match.mjs +70 -0
- package/tools/code-options.mjs +174 -0
- package/tools/conversation.mjs +49 -0
- package/tools/deck-family.mjs +101 -0
- package/tools/deck-html.mjs +212 -15
- package/tools/design-system-format.mjs +40 -1
- package/tools/design-system-migrations.mjs +207 -0
- package/tools/diagram-shapes.mjs +221 -0
- package/tools/elevenlabs-tts.mjs +62 -53
- package/tools/exec.mjs +10 -2
- package/tools/face-clip.mjs +96 -0
- package/tools/face-layout.mjs +94 -0
- package/tools/gemini-tts.mjs +1 -1
- package/tools/invisible-in-print.mjs +27 -0
- package/tools/lipsync-auto.mjs +197 -0
- package/tools/lipsync-config.mjs +16 -0
- package/tools/lipsync-engines.mjs +22 -4
- package/tools/lipsync-server.mjs +8 -5
- package/tools/lipsync.mjs +122 -30
- package/tools/local-voice.mjs +1 -1
- package/tools/mouth-file.mjs +26 -0
- package/tools/mouth.mjs +320 -0
- package/tools/narration-manifest.mjs +100 -6
- package/tools/narration-synth.mjs +96 -76
- package/tools/recording-impact.mjs +16 -1
- package/tools/sentences.mjs +7 -1
- package/tools/site-clip.mjs +114 -0
- package/tools/starters.mjs +402 -0
- package/tools/steps.mjs +118 -0
- package/tools/take-check.mjs +146 -0
- package/tools/template-theme.mjs +3 -1
- package/tools/test-impact.mjs +36 -12
- package/tools/theme-check.mjs +196 -1
- package/tools/tone-cue.mjs +108 -0
- package/tools/tts-cache.mjs +9 -3
- package/tools/tts-engines.mjs +100 -11
- package/tools/video-cache.mjs +93 -0
- package/tools/video-live.mjs +349 -0
- package/tools/video-options.mjs +11 -0
- package/tools/video.mjs +825 -117
- package/tools/viseme-fit.mjs +27 -0
- package/tools/viseme-match.mjs +77 -0
- package/tools/vocabulary.mjs +397 -0
- package/tools/voice-renumber.mjs +605 -0
- package/tools/voiceover-server.mjs +42 -11
- package/tools/voiceover.mjs +48 -20
- package/dist/build-info.json +0 -1
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// The author's code editor (PRESENTING_EDITING, Open in your editor): which
|
|
5
|
+
// one, where it is on this machine, and the argument list that opens a file
|
|
6
|
+
// at a line and a column in it.
|
|
7
|
+
//
|
|
8
|
+
// The command that runs is never the request's. It is built here from the
|
|
9
|
+
// author's saved choice and the deck being served, and it is spawned as an
|
|
10
|
+
// argument array with no shell, so a file name, a line or a template's words
|
|
11
|
+
// are always arguments and never a command line for a shell to re-split.
|
|
12
|
+
//
|
|
13
|
+
// The choice is remembered beside the voice settings (tools/tts-setup.mjs:
|
|
14
|
+
// ~/.config/decklight/, $XDG_CONFIG_HOME honoured), in editor.json:
|
|
15
|
+
//
|
|
16
|
+
// { "editor": "vscode" | "cursor" | "zed" | "env" }
|
|
17
|
+
// { "editor": "custom", "template": "myedit --line {line} {file}" }
|
|
18
|
+
|
|
19
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import { spawn as nodeSpawn } from 'node:child_process';
|
|
21
|
+
import path, { dirname, join } from 'node:path';
|
|
22
|
+
import { homedir } from 'node:os';
|
|
23
|
+
import { ttsConfigPath } from '../tools/tts-setup.mjs';
|
|
24
|
+
import { whichBin } from './agents.mjs';
|
|
25
|
+
|
|
26
|
+
/** `file:line:column`, the address the VS Code family, Zed and Sublime Text read. */
|
|
27
|
+
const at = (f, l, c) => `${f}:${l}:${c}`;
|
|
28
|
+
const GOTO = (f, l, c) => ['-g', at(f, l, c)];
|
|
29
|
+
const PLAIN = (f, l, c) => [at(f, l, c)];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The editors offered by name. `apps` are where macOS keeps each one's command
|
|
33
|
+
* line tool inside its app bundle, for the common case of an editor installed
|
|
34
|
+
* without its "shell command" put on PATH.
|
|
35
|
+
*/
|
|
36
|
+
export const EDITORS = [
|
|
37
|
+
{ id: 'vscode', label: 'VS Code', bin: 'code', args: GOTO,
|
|
38
|
+
apps: ['Visual Studio Code.app/Contents/Resources/app/bin/code'] },
|
|
39
|
+
{ id: 'cursor', label: 'Cursor', bin: 'cursor', args: GOTO,
|
|
40
|
+
apps: ['Cursor.app/Contents/Resources/app/bin/cursor'] },
|
|
41
|
+
{ id: 'zed', label: 'Zed', bin: 'zed', args: PLAIN,
|
|
42
|
+
apps: ['Zed.app/Contents/MacOS/cli', 'Zed Preview.app/Contents/MacOS/cli'] },
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
/** $VISUAL / $EDITOR programs that open a window of their own, and how each is sent to a line. */
|
|
46
|
+
const GUI = {
|
|
47
|
+
code: { label: 'VS Code', args: GOTO },
|
|
48
|
+
'code-insiders': { label: 'VS Code Insiders', args: GOTO },
|
|
49
|
+
codium: { label: 'VSCodium', args: GOTO },
|
|
50
|
+
cursor: { label: 'Cursor', args: GOTO },
|
|
51
|
+
windsurf: { label: 'Windsurf', args: GOTO },
|
|
52
|
+
zed: { label: 'Zed', args: PLAIN },
|
|
53
|
+
subl: { label: 'Sublime Text', args: PLAIN },
|
|
54
|
+
mate: { label: 'TextMate', args: (f, l, c) => ['-l', `${l}:${c}`, f] },
|
|
55
|
+
};
|
|
56
|
+
/** Programs that need a terminal to draw in, which a server in the background does not have. */
|
|
57
|
+
const TERMINAL = new Set(['vi', 'vim', 'nvim', 'view', 'nano', 'pico', 'micro', 'hx', 'helix', 'kak', 'joe', 'ne', 'ed', 'mg', 'emacs', 'jed', 'vis']);
|
|
58
|
+
/** The flags that make an editor hold its caller until the file is closed: nobody here is waiting. */
|
|
59
|
+
const WAIT_FLAGS = new Set(['-w', '--wait', '-W']);
|
|
60
|
+
|
|
61
|
+
/** The three placeholders a template may carry. */
|
|
62
|
+
const PLACEHOLDERS = /\{(file|line|column)\}/g;
|
|
63
|
+
|
|
64
|
+
// ── the remembered choice ─────────────────────────────────────────────────
|
|
65
|
+
|
|
66
|
+
/** editor.json, beside tts.json: ~/.config/decklight/editor.json, $XDG_CONFIG_HOME honoured. */
|
|
67
|
+
export const editorConfigPath = (env = process.env) => join(dirname(ttsConfigPath(env)), 'editor.json');
|
|
68
|
+
|
|
69
|
+
/** The saved choice, or null: a missing, unreadable or malformed file is first use. */
|
|
70
|
+
export function loadEditorChoice(env = process.env) {
|
|
71
|
+
let saved;
|
|
72
|
+
try { saved = JSON.parse(readFileSync(editorConfigPath(env), 'utf8')); } catch { return null; }
|
|
73
|
+
try { return checkChoice(saved); } catch { return null; }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Remember `choice` (checked first: a bad one is a throw, never a file); null forgets it. */
|
|
77
|
+
export function saveEditorChoice(choice, env = process.env) {
|
|
78
|
+
const file = editorConfigPath(env);
|
|
79
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
80
|
+
writeFileSync(file, `${JSON.stringify(choice === null ? {} : checkChoice(choice), null, 2)}\n`);
|
|
81
|
+
return file;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** `{ editor, template? }` if it is a choice this module can act on, or a throw that says why. */
|
|
85
|
+
export function checkChoice(choice) {
|
|
86
|
+
if (!choice || typeof choice !== 'object' || Array.isArray(choice)) throw new Error('no editor named');
|
|
87
|
+
const { editor } = choice;
|
|
88
|
+
if (EDITORS.some((e) => e.id === editor) || editor === 'env') return { editor };
|
|
89
|
+
if (editor !== 'custom') throw new Error(`no editor called ${JSON.stringify(String(editor)).slice(0, 40)}`);
|
|
90
|
+
parseTemplate(choice.template);
|
|
91
|
+
return { editor, template: choice.template.trim() };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ── a command of your own ─────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A template's words, the way a shell would split them for the simple cases
|
|
98
|
+
* (spaces, and "double" or 'single' quotes around a word with spaces), but
|
|
99
|
+
* never handed to one. The first word is the program; `{file}` must be
|
|
100
|
+
* somewhere, and the program itself carries no placeholder.
|
|
101
|
+
*/
|
|
102
|
+
export function parseTemplate(template) {
|
|
103
|
+
if (typeof template !== 'string' || !template.trim()) throw new Error('the command is empty');
|
|
104
|
+
if (template.length > 500) throw new Error('the command is too long');
|
|
105
|
+
// eslint-disable-next-line no-control-regex
|
|
106
|
+
if (/[\u0000-\u001f\u007f]/.test(template)) throw new Error('the command is one line, with no control characters');
|
|
107
|
+
const words = [];
|
|
108
|
+
const re = /"([^"]*)"|'([^']*)'|(\S+)/g;
|
|
109
|
+
for (let m = re.exec(template); m; m = re.exec(template)) words.push(m[1] ?? m[2] ?? m[3]);
|
|
110
|
+
if (/["']/.test(template.replace(/"[^"]*"|'[^']*'/g, ''))) throw new Error('a quote in the command is not closed');
|
|
111
|
+
if (!words.length) throw new Error('the command is empty');
|
|
112
|
+
if (/\{(file|line|column)\}/.test(words[0])) throw new Error('the command must start with a program, not a placeholder');
|
|
113
|
+
if (!words.some((w) => w.includes('{file}'))) throw new Error('the command must say where the file goes: {file}');
|
|
114
|
+
return words;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The template's words with `{file}`, `{line}` and `{column}` filled in, one argument each word. */
|
|
118
|
+
export const fillTemplate = (words, { file, line, column }) =>
|
|
119
|
+
words.map((w) => w.replace(PLACEHOLDERS, (_, k) => String({ file, line, column }[k])));
|
|
120
|
+
|
|
121
|
+
/** A command line read as words (no shell), quotes kept off: for $VISUAL and $EDITOR. */
|
|
122
|
+
const splitWords = (s) => [...String(s).matchAll(/"([^"]*)"|'([^']*)'|(\S+)/g)].map((m) => m[1] ?? m[2] ?? m[3]);
|
|
123
|
+
|
|
124
|
+
// ── $VISUAL / $EDITOR ─────────────────────────────────────────────────────
|
|
125
|
+
|
|
126
|
+
/** The program a path names, without a Windows extension: `/usr/local/bin/code` and `code.cmd` are `code`. */
|
|
127
|
+
const programName = (bin) => path.basename(String(bin).replace(/\\/g, '/')).replace(/\.(exe|cmd|bat)$/i, '').toLowerCase();
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* What $VISUAL (else $EDITOR) names, and whether it can be sent to a line
|
|
131
|
+
* from here: `{ name, value, program, words, label, gui?, blocked? }`, or
|
|
132
|
+
* null when neither is set. A terminal editor is `blocked` with the reason;
|
|
133
|
+
* it is never run and left to fail where nobody can see it.
|
|
134
|
+
*/
|
|
135
|
+
export function envEditor(env = process.env) {
|
|
136
|
+
const name = env.VISUAL?.trim() ? 'VISUAL' : env.EDITOR?.trim() ? 'EDITOR' : null;
|
|
137
|
+
if (!name) return null;
|
|
138
|
+
const value = env[name].trim();
|
|
139
|
+
const [program, ...rest] = splitWords(value);
|
|
140
|
+
const words = rest.filter((w) => !WAIT_FLAGS.has(w));
|
|
141
|
+
const prog = programName(program);
|
|
142
|
+
const gui = GUI[prog] ?? null;
|
|
143
|
+
const label = `${gui?.label ?? prog} ($${name})`;
|
|
144
|
+
const blocked = gui ? null
|
|
145
|
+
: TERMINAL.has(prog) ? `${prog} runs in a terminal, and the deck's server has none to open it in`
|
|
146
|
+
: `decklight does not know how to send ${prog} to a line`;
|
|
147
|
+
return { name, value, program, words, label, gui, blocked };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ── where each one is ─────────────────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
/** The app bundles' own command line tools, macOS only: /Applications and ~/Applications. */
|
|
153
|
+
function appPath(editor, { env, platform, exists }) {
|
|
154
|
+
if (platform !== 'darwin') return null;
|
|
155
|
+
const home = env.HOME || homedir();
|
|
156
|
+
// posix joins throughout: these are macOS paths whatever machine is asking (the
|
|
157
|
+
// host's own join wrote ~\Applications on Windows, and nothing was found there)
|
|
158
|
+
for (const base of ['/Applications', path.posix.join(home, 'Applications')]) {
|
|
159
|
+
for (const rel of editor.apps ?? []) {
|
|
160
|
+
const file = path.posix.join(base, rel);
|
|
161
|
+
if (exists(file)) return file;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Where `editor` runs from here: on PATH first, else its app bundle; null when it is not installed. */
|
|
168
|
+
export function locate(editor, { env = process.env, platform = process.platform, exists = existsSync } = {}) {
|
|
169
|
+
const onPath = whichBin(editor.bin, env, platform, exists);
|
|
170
|
+
if (onPath) return { bin: onPath, where: 'PATH' };
|
|
171
|
+
const app = appPath(editor, { env, platform, exists });
|
|
172
|
+
return app ? { bin: app, where: 'app' } : null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* What the chooser lists: the named editors this machine has, then what
|
|
177
|
+
* $VISUAL or $EDITOR names (blocked, with the reason, when it cannot be
|
|
178
|
+
* sent to a line), then a command of your own. `[{ id, label, note?,
|
|
179
|
+
* blocked? }]`; nothing here is a path to run.
|
|
180
|
+
*/
|
|
181
|
+
export function detectEditors({ env = process.env, platform = process.platform, exists = existsSync } = {}) {
|
|
182
|
+
const out = [];
|
|
183
|
+
for (const e of EDITORS) {
|
|
184
|
+
const found = locate(e, { env, platform, exists });
|
|
185
|
+
if (found) out.push({ id: e.id, label: e.label, ...(found.where === 'app' ? { note: 'from its app' } : {}) });
|
|
186
|
+
}
|
|
187
|
+
const own = envEditor(env);
|
|
188
|
+
// its label names the program, never the variable's whole value: the page needs no more of the server's environment
|
|
189
|
+
if (own) out.push({ id: 'env', label: own.label, ...(own.blocked ? { blocked: own.blocked } : {}) });
|
|
190
|
+
out.push({ id: 'custom', label: 'A command of your own…', note: 'with {file}, {line} and {column}' });
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** The label a saved choice reads as, for the page. */
|
|
195
|
+
export function choiceLabel(choice, { env = process.env } = {}) {
|
|
196
|
+
if (!choice) return null;
|
|
197
|
+
if (choice.editor === 'custom') return `your command (${programName(parseTemplate(choice.template)[0])})`;
|
|
198
|
+
if (choice.editor === 'env') return envEditor(env)?.label ?? '$VISUAL or $EDITOR';
|
|
199
|
+
return EDITORS.find((e) => e.id === choice.editor)?.label ?? choice.editor;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ── the command ───────────────────────────────────────────────────────────
|
|
203
|
+
|
|
204
|
+
/** The app a VS Code-style `bin\<name>.cmd` shim starts, by the shim's name. */
|
|
205
|
+
const ELECTRON_EXE = { code: 'Code.exe', cursor: 'Cursor.exe' };
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* What a Windows VS Code or Cursor shim (`<install>\bin\code.cmd`) runs,
|
|
209
|
+
* without cmd.exe: the app (`<install>\Code.exe`) as node, on its CLI script
|
|
210
|
+
* (`<install>\resources\app\out\cli.js`), which is what the shim does
|
|
211
|
+
* with ELECTRON_RUN_AS_NODE set. `{ exe, cli }`, or null when the shim is not
|
|
212
|
+
* one of theirs or either file is not where that layout puts it.
|
|
213
|
+
*/
|
|
214
|
+
export function electronShim(cmd, { exists = existsSync } = {}) {
|
|
215
|
+
const w = path.win32;
|
|
216
|
+
const exeName = ELECTRON_EXE[programName(cmd)];
|
|
217
|
+
if (!exeName || w.basename(w.dirname(cmd)).toLowerCase() !== 'bin') return null;
|
|
218
|
+
const install = w.dirname(w.dirname(cmd));
|
|
219
|
+
// Cursor has kept its shim inside the app (`<install>\resources\app\bin`):
|
|
220
|
+
// the same two files, reached from there
|
|
221
|
+
const roots = /\\resources\\app$/i.test(install) ? [install, w.dirname(w.dirname(install))] : [install];
|
|
222
|
+
for (const root of roots) {
|
|
223
|
+
const exe = w.join(root, exeName);
|
|
224
|
+
const cli = w.join(root, 'resources', 'app', 'out', 'cli.js');
|
|
225
|
+
if (exists(exe) && exists(cli)) return { exe, cli };
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The argument array that opens `file` at `line`:`column` in the saved
|
|
232
|
+
* editor: `{ ok: true, bin, args, label }`, or `{ ok: false, reason, error }`
|
|
233
|
+
* where `reason` is `unset`, `missing`, `terminal` or `unknown` and `error`
|
|
234
|
+
* is a sentence for the page. Nothing is run.
|
|
235
|
+
*/
|
|
236
|
+
export function editorCommand(choice, { file, line, column }, { env = process.env, platform = process.platform, exists = existsSync } = {}) {
|
|
237
|
+
if (!choice) return { ok: false, reason: 'unset', error: 'no code editor chosen yet' };
|
|
238
|
+
const label = choiceLabel(choice, { env });
|
|
239
|
+
const runnable = (bin, args) => {
|
|
240
|
+
// Node starts a .cmd or a .bat only through cmd.exe, and nothing here
|
|
241
|
+
// goes through a shell. VS Code's and Cursor's own shims are started the
|
|
242
|
+
// way they start themselves (electronShim); any other is said, never half-run
|
|
243
|
+
if (platform === 'win32' && /\.(cmd|bat)$/i.test(bin)) {
|
|
244
|
+
const shim = electronShim(bin, { exists });
|
|
245
|
+
if (shim) return { ok: true, bin: shim.exe, args: [shim.cli, ...args], env: { ELECTRON_RUN_AS_NODE: '1' }, label };
|
|
246
|
+
return { ok: false, reason: 'missing', error: `${label} is a batch file here, and decklight starts editors without a shell: choose a command that names the program itself` };
|
|
247
|
+
}
|
|
248
|
+
return { ok: true, bin, args, label };
|
|
249
|
+
};
|
|
250
|
+
if (choice.editor === 'custom') {
|
|
251
|
+
const words = parseTemplate(choice.template);
|
|
252
|
+
const bin = whichBin(words[0], env, platform, exists);
|
|
253
|
+
if (!bin) return { ok: false, reason: 'missing', error: `your command's program, ${words[0]}, is not on this machine` };
|
|
254
|
+
return runnable(bin, fillTemplate(words.slice(1), { file, line, column }));
|
|
255
|
+
}
|
|
256
|
+
if (choice.editor === 'env') {
|
|
257
|
+
const own = envEditor(env);
|
|
258
|
+
if (!own) return { ok: false, reason: 'missing', error: '$VISUAL and $EDITOR are not set for the deck\'s server' };
|
|
259
|
+
if (own.blocked) return { ok: false, reason: TERMINAL.has(programName(own.program)) ? 'terminal' : 'unknown', error: own.blocked };
|
|
260
|
+
const bin = whichBin(own.program, env, platform, exists);
|
|
261
|
+
if (!bin) return { ok: false, reason: 'missing', error: `${own.label} names ${own.program}, which is not on this machine` };
|
|
262
|
+
return runnable(bin, [...own.words, ...own.gui.args(file, line, column)]);
|
|
263
|
+
}
|
|
264
|
+
const editor = EDITORS.find((e) => e.id === choice.editor);
|
|
265
|
+
if (!editor) return { ok: false, reason: 'unset', error: 'no code editor chosen yet' };
|
|
266
|
+
const found = locate(editor, { env, platform, exists });
|
|
267
|
+
if (!found) return { ok: false, reason: 'missing', error: `${editor.label} is not installed here, or not where decklight looks for it` };
|
|
268
|
+
return runnable(found.bin, editor.args(file, line, column));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Start the editor and let it go: detached, its output ignored, never
|
|
273
|
+
* waited for (an editor's CLI hands the file to the open window and exits;
|
|
274
|
+
* one that stays is its own). Resolves once it started, `{ ok: true }`, or
|
|
275
|
+
* failed to, `{ ok: false, error }`; `spawn` is injected by the tests.
|
|
276
|
+
*/
|
|
277
|
+
export function launchEditor({ bin, args, env = null }, { spawn = nodeSpawn, cwd, baseEnv = process.env } = {}) {
|
|
278
|
+
return new Promise((done) => {
|
|
279
|
+
let child;
|
|
280
|
+
try {
|
|
281
|
+
child = spawn(bin, args, { detached: true, stdio: 'ignore', shell: false, windowsHide: true,
|
|
282
|
+
...(cwd ? { cwd } : {}), ...(env ? { env: { ...baseEnv, ...env } } : {}) });
|
|
283
|
+
} catch (e) { done({ ok: false, error: String(e.message || e) }); return; }
|
|
284
|
+
child.once('error', (e) => done({ ok: false, error: e.code === 'ENOENT' ? `${bin} was not found` : String(e.message || e) }));
|
|
285
|
+
child.once('spawn', () => { child.unref?.(); done({ ok: true }); });
|
|
286
|
+
});
|
|
287
|
+
}
|
package/cli/commands.mjs
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
export const COMMANDS = {
|
|
30
30
|
init: { module: './init.mjs', main: 'initMain' },
|
|
31
31
|
skills: { module: './skills.mjs', main: 'skillsMain' },
|
|
32
|
+
vscode: { module: './editor-support.mjs', main: 'vscodeMain' },
|
|
32
33
|
cast: { module: './cast.mjs', main: 'castMain' },
|
|
33
34
|
// `cast refresh` and `cast export` are castMain's own subcommands. They
|
|
34
35
|
// used to be top-level `refresh` and `export` too, and a top-level `export`
|
|
@@ -64,6 +65,7 @@ export const COMMANDS = {
|
|
|
64
65
|
// command for what `voiceover` and `record` did (cli/narrate.mjs)
|
|
65
66
|
narrate: { module: './narrate.mjs', main: 'narrateMain' },
|
|
66
67
|
enhance: { module: './enhance.mjs', main: 'enhanceMain' },
|
|
68
|
+
translate: { module: './translate.mjs', main: 'translateMain' },
|
|
67
69
|
comments: { module: './comments.mjs', main: 'commentsMain' },
|
|
68
70
|
associate: { module: './associate.mjs', main: 'associateMain' },
|
|
69
71
|
'report-bug': { module: './report-bug.mjs', main: 'reportBugMain' },
|
|
@@ -253,6 +255,10 @@ Commands:
|
|
|
253
255
|
EXAMPLE: decklight skills claude codex (or --all, or omit to use detected agents)
|
|
254
256
|
EXAMPLE: decklight skills --global (install into each agent's config home, every project)
|
|
255
257
|
EXAMPLE: decklight skills claude --pack (zip it to upload in your claude.ai skill settings)
|
|
258
|
+
vscode write .vscode/ beside a deck: completions for every data-* attribute Decklight reads,
|
|
259
|
+
with its values, and dl- snippets (a slide, a build, notes, a diagram, a chart, a
|
|
260
|
+
comparison); settings.json is merged, never overwritten. init --vscode does it for a new deck
|
|
261
|
+
EXAMPLE: decklight vscode deck.html
|
|
256
262
|
cast record a truthful terminal cast by running a YAML command script in a real PTY
|
|
257
263
|
(this records a TERMINAL — decklight narrate --mic records your VOICE)
|
|
258
264
|
EXAMPLE: decklight cast deck.term.yaml -o deck.cast.json
|
|
@@ -304,7 +310,7 @@ Commands:
|
|
|
304
310
|
you open uses them
|
|
305
311
|
EXAMPLE: decklight setup voice (which engine, what it needs, one test sentence)
|
|
306
312
|
EXAMPLE: decklight setup face --portrait me=me.jpg --wav2lip-dir ~/Wav2Lip --wav2lip-ckpt …
|
|
307
|
-
video render the deck to ONE narrated mp4 —
|
|
313
|
+
video render the deck to ONE narrated mp4 — each slide held for its narration audio, moving where it moves
|
|
308
314
|
EXAMPLE: decklight video deck.html -o deck.mp4 (add --voiceover to synthesize first)
|
|
309
315
|
EXAMPLE: decklight video deck.html --slides 5-9 --voiceover (just those slides, voiced)
|
|
310
316
|
EXAMPLE: decklight video deck.html --format webm --quality high --subtitles file
|
|
@@ -318,6 +324,10 @@ Commands:
|
|
|
318
324
|
enhance add ElevenLabs v4 audio tags ([thoughtful], [sighs]) to the voiceover script, with the
|
|
319
325
|
prompt ElevenLabs publishes for it — your agent drafts, decklight checks no word changed
|
|
320
326
|
EXAMPLE: decklight enhance talk.html --slides 3 (or --all; --dry-run to only look)
|
|
327
|
+
translate the deck in another language beside it (talk.fr.html), made from it with its words
|
|
328
|
+
replaced by your agent, and a record of what each piece was translated from, so a
|
|
329
|
+
second run translates only what changed and keeps every correction you made
|
|
330
|
+
EXAMPLE: decklight translate talk.html --to fr (--status: what is behind, no agent)
|
|
321
331
|
comments what reviewers said, resolved against the deck as it is now — a comment
|
|
322
332
|
whose slide moved is found anyway, and one whose slide is gone is still shown;
|
|
323
333
|
a reviewer leaves them with M in a deck opened either way (--no-trust for one
|
|
@@ -339,7 +349,8 @@ Commands:
|
|
|
339
349
|
looking — clipped content, a crowded slide, an asset that is not on disk, [click] beats
|
|
340
350
|
that do not line up with the builds; exit 1 on an error (an agent after every edit,
|
|
341
351
|
you before a talk); in the deck, the palette's Check deck… lists the same
|
|
342
|
-
EXAMPLE: decklight check deck.html (--json for an agent, --no-render without Chrome
|
|
352
|
+
EXAMPLE: decklight check deck.html (--json for an agent, --no-render without Chrome,
|
|
353
|
+
--watch to check again on every save until Ctrl-C)
|
|
343
354
|
help show this help, or a command's help: decklight help bundle
|
|
344
355
|
version print the installed version (also --version / -v)
|
|
345
356
|
`;
|
package/cli/commit-flow.mjs
CHANGED
|
@@ -176,7 +176,11 @@ export function nagText({ lines = 0, sinceMs = 0 } = {}) {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
/** The line `open` prints when the snapshot is what stands behind the nag. */
|
|
179
|
-
export function wipLine(deckRel) {
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
export function wipLine(deckRel, { untracked = false } = {}) {
|
|
180
|
+
// An untracked deck is not committed until K (edit.mjs startGit), so the
|
|
181
|
+
// line says that rather than promising a commit nobody asked for.
|
|
182
|
+
const lead = untracked
|
|
183
|
+
? ` git: ${deckRel} is not in git: K adds it — until then a silent snapshot rides on`
|
|
184
|
+
: ` git: committing ${deckRel} when you say so — a silent snapshot rides on`;
|
|
185
|
+
return `${lead} ${WIP_REF.replace('refs/', '')} in between (git show decklight/wip:${deckRel})`;
|
|
182
186
|
}
|
package/cli/commit-message.mjs
CHANGED
|
@@ -33,6 +33,7 @@ import { readFileSync } from 'node:fs';
|
|
|
33
33
|
import { basename, relative, resolve as resolvePath } from 'node:path';
|
|
34
34
|
import { agentAsk } from './agents.mjs';
|
|
35
35
|
import { commitSubject, git } from './git.mjs';
|
|
36
|
+
import { slideName } from '../tools/deck-html.mjs';
|
|
36
37
|
|
|
37
38
|
/** How much diff the agent is shown. */
|
|
38
39
|
export const MAX_DIFF = 24 * 1024;
|
|
@@ -138,6 +139,20 @@ export function changedSlides(html, diff) {
|
|
|
138
139
|
return slides.filter((s) => hit.has(s.index));
|
|
139
140
|
}
|
|
140
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Each slide's name as a commit subject says it (`slideName`), indexed by
|
|
144
|
+
* slide number minus one. Pure. Read off `deckOutline`, so a nested
|
|
145
|
+
* `<section>` is part of its slide rather than a slide of its own.
|
|
146
|
+
*/
|
|
147
|
+
export function slideNames(html) {
|
|
148
|
+
const lines = String(html ?? '').split('\n');
|
|
149
|
+
return deckOutline(html).map((s) => {
|
|
150
|
+
const src = lines.slice(s.from - 1, s.to).join('\n');
|
|
151
|
+
const at = src.search(/<section\b/i);
|
|
152
|
+
return slideName(at === -1 ? src : src.slice(at + '<section'.length));
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
141
156
|
/** `<title>` — what the deck calls itself. */
|
|
142
157
|
export function deckTitle(html) {
|
|
143
158
|
const m = /<title[^>]*>([\s\S]*?)<\/title>/i.exec(String(html ?? ''));
|
|
@@ -271,6 +286,7 @@ export function ask(cmd, cwd, timeoutMs) {
|
|
|
271
286
|
try {
|
|
272
287
|
child = execFile(cmd.bin, cmd.args, {
|
|
273
288
|
cwd,
|
|
289
|
+
env: cmd.env,
|
|
274
290
|
timeout: timeoutMs,
|
|
275
291
|
maxBuffer: 4 * 1024 * 1024,
|
|
276
292
|
// The agent is being asked a question about a diff it is given in the
|
|
@@ -280,6 +296,10 @@ export function ask(cmd, cwd, timeoutMs) {
|
|
|
280
296
|
}, (err, stdout) => finish(err && !stdout ? null : String(stdout ?? '')));
|
|
281
297
|
} catch { return finish(null); }
|
|
282
298
|
child.on('error', () => finish(null));
|
|
299
|
+
// execFile pipes stdin whatever `stdio` says, and `claude -p` waits 3 s on
|
|
300
|
+
// an open pipe nobody writes to (#908): closed, it reads EOF at once.
|
|
301
|
+
child.stdin?.on('error', () => {});
|
|
302
|
+
child.stdin?.end();
|
|
283
303
|
});
|
|
284
304
|
}
|
|
285
305
|
|
|
@@ -345,7 +365,7 @@ export async function describeCommit({
|
|
|
345
365
|
|
|
346
366
|
/**
|
|
347
367
|
* A subject for work that is NOT COMMITTED YET — what the commit overlay's
|
|
348
|
-
* "write
|
|
368
|
+
* "write it for me" button asks for.
|
|
349
369
|
*
|
|
350
370
|
* The same prompt, the same read-only argv, the same cap and the same stated
|
|
351
371
|
* truncation as `describeCommit`; three things differ, and each is because
|
|
@@ -371,6 +391,7 @@ export async function describeWorking({
|
|
|
371
391
|
const deck = basename(deckPath);
|
|
372
392
|
const rel = deckRel || relative(cwd, deckPath) || deck;
|
|
373
393
|
|
|
394
|
+
const deckHtml = () => { try { return (read ?? readFileSync)(deckPath, 'utf8'); } catch { return ''; } };
|
|
374
395
|
let out_;
|
|
375
396
|
try { out_ = run(['diff', '--unified=1', 'HEAD', '--', rel], cwd) ?? ''; }
|
|
376
397
|
catch { return null; }
|
|
@@ -386,7 +407,7 @@ export async function describeWorking({
|
|
|
386
407
|
try { side = run(['ls-files', '--others', '--exclude-standard', '--', other], cwd) ? (read ?? readFileSync)(resolvePath(cwd, other), 'utf8').split('\n').map((l) => `+${l}`).join('\n') : ''; }
|
|
387
408
|
catch { side = ''; }
|
|
388
409
|
}
|
|
389
|
-
const subject = reviewSubject(side);
|
|
410
|
+
const subject = reviewSubject(side, { names: slideNames(deckHtml()) });
|
|
390
411
|
if (subject) return subject;
|
|
391
412
|
}
|
|
392
413
|
return null;
|
|
@@ -396,8 +417,7 @@ export async function describeWorking({
|
|
|
396
417
|
const truncated = out_.length > MAX_DIFF;
|
|
397
418
|
const diff = truncated ? out_.slice(0, MAX_DIFF) : out_;
|
|
398
419
|
|
|
399
|
-
|
|
400
|
-
try { html = (read ?? readFileSync)(deckPath, 'utf8'); } catch { /* headings are optional */ }
|
|
420
|
+
const html = deckHtml(); // headings are optional
|
|
401
421
|
const prompt = messagePrompt({
|
|
402
422
|
deck, template, diff, truncated,
|
|
403
423
|
title: deckTitle(html),
|
|
@@ -417,10 +437,12 @@ export async function describeWorking({
|
|
|
417
437
|
|
|
418
438
|
/**
|
|
419
439
|
* A subject for a change that is only review records: the added lines of the
|
|
420
|
-
* sidecar's diff, read as records. One comment names its slide
|
|
421
|
-
*
|
|
440
|
+
* sidecar's diff, read as records. One comment names its slide, by its name
|
|
441
|
+
* in the deck as it is now (`names`, from `slideNames`) or the title the
|
|
442
|
+
* comment recorded, never by its number alone; several, or a mix, are
|
|
443
|
+
* counted. Null when nothing was added.
|
|
422
444
|
*/
|
|
423
|
-
export function reviewSubject(diff) {
|
|
445
|
+
export function reviewSubject(diff, { names = [] } = {}) {
|
|
424
446
|
const added = [];
|
|
425
447
|
for (const line of String(diff ?? '').split('\n')) {
|
|
426
448
|
if (!line.startsWith('+') || line.startsWith('+++')) continue;
|
|
@@ -430,7 +452,12 @@ export function reviewSubject(diff) {
|
|
|
430
452
|
const comments = added.filter((r) => !r.op && r.id);
|
|
431
453
|
const ops = added.filter((r) => r.op);
|
|
432
454
|
const count = (n, what) => `${n} ${what}${n === 1 ? '' : 's'}`;
|
|
433
|
-
if (comments.length === 1 && !ops.length)
|
|
455
|
+
if (comments.length === 1 && !ops.length) {
|
|
456
|
+
const { slide, title } = comments[0];
|
|
457
|
+
const name = names[slide - 1]
|
|
458
|
+
?? (title && !/^slide \d+$/i.test(title) ? `"${String(title).replace(/\s+/g, ' ').trim().slice(0, 40)}"` : null);
|
|
459
|
+
return name ? `review: a comment on ${name}` : 'review: a comment';
|
|
460
|
+
}
|
|
434
461
|
if (!comments.length && ops.length) {
|
|
435
462
|
const kinds = [...new Set(ops.map((r) => r.op))];
|
|
436
463
|
if (kinds.length === 1) {
|