decklight 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PLATFORM.md +707 -0
- package/README.md +226 -150
- package/SPEC.md +803 -888
- package/cli/agent-review.mjs +246 -0
- package/cli/agents.mjs +35 -9
- package/cli/associate.mjs +12 -12
- package/cli/audit.mjs +42 -10
- package/cli/banner.mjs +41 -17
- package/cli/bundle-audio.mjs +190 -0
- package/cli/bundle-module.mjs +95 -0
- package/cli/bundle.mjs +439 -35
- package/cli/cast.mjs +48 -12
- package/cli/check-fixes.mjs +186 -0
- package/cli/check.mjs +988 -0
- package/cli/clone-deck.mjs +179 -0
- package/cli/commands.mjs +345 -0
- package/cli/comments.mjs +64 -18
- package/cli/commit-flow.mjs +51 -22
- package/cli/commit-message.mjs +51 -74
- package/cli/commit-split.mjs +601 -0
- package/cli/deck-refs.mjs +64 -0
- package/cli/deck-routes.mjs +67 -0
- package/cli/deckfile.mjs +3 -5
- package/cli/decklight.mjs +68 -289
- package/cli/design-system-deps.mjs +209 -0
- package/cli/design-system-edit.mjs +194 -0
- package/cli/design-system-refs.mjs +666 -0
- package/cli/design-system.mjs +497 -0
- package/cli/doctor.mjs +115 -0
- package/cli/edit-git.mjs +353 -0
- package/cli/edit-handover.mjs +551 -0
- package/cli/edit-look.mjs +631 -0
- package/cli/edit-slides.mjs +683 -0
- package/cli/edit.mjs +2585 -855
- package/cli/enhance.mjs +485 -0
- package/cli/extension.mjs +10 -10
- package/cli/font-refs.mjs +273 -0
- package/cli/font.mjs +246 -0
- package/cli/git-tree.mjs +1 -1
- package/cli/git.mjs +78 -11
- package/cli/import.mjs +56 -10
- package/cli/init.mjs +407 -236
- package/cli/library.mjs +127 -0
- package/cli/loader.mjs +3 -1
- package/cli/marketplace-autocheck.mjs +200 -0
- package/cli/marketplace.mjs +460 -29
- package/cli/narrate.mjs +251 -0
- package/cli/open-browser.mjs +63 -0
- package/cli/open.mjs +961 -0
- package/cli/pdf.mjs +64 -17
- package/cli/pkg.mjs +44 -2
- package/cli/plugin.mjs +43 -41
- package/cli/port-conflict.mjs +53 -23
- package/cli/pptx-export.mjs +63 -27
- package/cli/publish.mjs +8 -4
- package/cli/qr.mjs +1 -1
- package/cli/record.mjs +85 -23
- package/cli/remote.mjs +43 -17
- package/cli/restore.mjs +11 -4
- package/cli/review-ref.mjs +125 -0
- package/cli/review-remote.mjs +92 -48
- package/cli/review-routes.mjs +254 -0
- package/cli/review-store.mjs +47 -7
- package/cli/review-submit.mjs +47 -57
- package/cli/runtime-link.mjs +560 -0
- package/cli/serve.mjs +236 -45
- package/cli/setup.mjs +112 -0
- package/cli/sign.mjs +1 -1
- package/cli/skill-content.mjs +229 -35
- package/cli/skills.mjs +353 -26
- package/cli/start.mjs +110 -0
- package/cli/supervise.mjs +6 -6
- package/cli/theme-refs.mjs +527 -0
- package/cli/theme.mjs +181 -137
- package/cli/trust.mjs +83 -0
- package/cli/units.mjs +112 -47
- package/cli/update-check.mjs +1 -5
- package/cli/upgrade.mjs +194 -28
- package/cli/upstream.mjs +4 -3
- package/cli/util.mjs +4 -4
- package/cli/wizard.mjs +6 -6
- package/dist/build-info.json +1 -1
- package/dist/decklight.css +1533 -59
- package/dist/decklight.js +258 -115
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +141 -0
- package/docs/architecture.svg +17 -17
- package/package.json +4 -2
- package/themes/README.md +9 -8
- package/themes/reveal-solarized.css +10 -0
- package/tools/args.mjs +20 -0
- package/tools/atomic-write.mjs +48 -0
- package/tools/brand-palette.mjs +717 -0
- package/tools/bridge.mjs +1 -1
- package/tools/build-groups.mjs +42 -0
- package/tools/color.mjs +48 -0
- package/tools/deck-html.mjs +396 -11
- package/tools/design-system-format.mjs +778 -0
- package/tools/design-system-migrations.mjs +207 -0
- package/tools/elevenlabs-tts.mjs +110 -17
- package/tools/exec.mjs +11 -3
- package/tools/extension-check.mjs +31 -7
- package/tools/font-format.mjs +190 -0
- package/tools/font-stacks.mjs +24 -0
- package/tools/gemini-tts.mjs +3 -0
- package/tools/lipsync-config.mjs +103 -0
- package/tools/lipsync-engines.mjs +205 -2
- package/tools/lipsync-server.mjs +264 -41
- package/tools/lipsync.mjs +37 -18
- package/tools/local-voice.mjs +32 -42
- package/tools/narration-manifest.mjs +270 -0
- package/tools/narration-synth.mjs +416 -0
- package/tools/pptx.mjs +776 -19
- package/tools/publish-targets.mjs +1 -1
- package/tools/publish-voices.mjs +3 -3
- package/tools/recording-impact.mjs +7 -3
- package/tools/render-theme.mjs +33 -0
- package/tools/review-anchor.mjs +28 -12
- package/tools/semver.mjs +40 -0
- package/tools/sentences.mjs +180 -0
- package/tools/shot.mjs +14 -7
- package/tools/site-clip.mjs +114 -0
- package/tools/site-voices.mjs +232 -0
- package/tools/template-theme.mjs +1 -1
- package/tools/test-impact.mjs +17 -10
- package/tools/theme-check.mjs +30 -3
- package/tools/tts-cache.mjs +4 -3
- package/tools/tts-engines.mjs +38 -20
- package/tools/tts-setup.mjs +7 -7
- package/tools/video-options.mjs +34 -0
- package/tools/video.mjs +530 -54
- package/tools/voiceover-server.mjs +185 -104
- package/tools/voiceover.mjs +119 -261
- package/tools/zip.mjs +1 -1
- package/cli/dev.mjs +0 -623
- package/cli/present.mjs +0 -853
- package/cli/review.mjs +0 -361
- package/tools/publish-site-voices.mjs +0 -75
package/cli/cast.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* decklight-cast — record truthful terminal casts for Decklight decks (SPEC RECORDER_CLI/CAST_FORMAT).
|
|
7
7
|
*
|
|
8
8
|
* decklight cast <script.term.yaml> [-o out.cast.json] [--allow-fail] [--quiet]
|
|
9
|
-
* decklight refresh <dir | cast.json…> [--allow-fail]
|
|
9
|
+
* decklight cast refresh <dir | cast.json…> [--allow-fail]
|
|
10
10
|
*
|
|
11
11
|
* This briefly shipped as `decklight rec`, a name dropped without an alias or
|
|
12
12
|
* a refusal stub: `rec` reads as an abbreviation of `record`, and `decklight
|
|
@@ -113,6 +113,23 @@ function shellArgs(shellPath) {
|
|
|
113
113
|
return [];
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* The two lines a step is written as: the command in a brace group, and the
|
|
118
|
+
* sentinel that marks its end. A command stopped with Ctrl-C (an `interact`
|
|
119
|
+
* send of \u0003, the way a server is ended) used to take the sentinel with
|
|
120
|
+
* it: an interactive shell abandons the rest of the line on an interrupt, so
|
|
121
|
+
* the marker never printed and the step timed out. zsh's `always` block runs
|
|
122
|
+
* after an interrupt and bash's INT trap fires on one, both printing the
|
|
123
|
+
* marker with the interrupt's status (130); any other shell keeps the plain
|
|
124
|
+
* form.
|
|
125
|
+
*/
|
|
126
|
+
export function stepLine(shellBase, cmd) {
|
|
127
|
+
const mark = (status) => `printf '${GS_OCTAL}DECKLIGHT:%d:${GS_OCTAL}\\n' ${status}`;
|
|
128
|
+
if (shellBase === 'zsh') return `{\n${cmd}\n} always { ${mark('$?')} }\n`;
|
|
129
|
+
if (shellBase === 'bash') return `trap "${mark(130).replace(/"/g, '\\"')}" INT; {\n${cmd}\n}; ${mark('$?')}; trap - INT\n`;
|
|
130
|
+
return `{\n${cmd}\n}; ${mark('$?')}\n`;
|
|
131
|
+
}
|
|
132
|
+
|
|
116
133
|
function setupLine(shellBase) {
|
|
117
134
|
const common = `stty -echo; printf '${GS_OCTAL}DECKLIGHT-READY${GS_OCTAL}\\n'`;
|
|
118
135
|
if (shellBase === 'zsh') return `unsetopt zle prompt_cr prompt_sp banghist 2>/dev/null; PS1=''; PROMPT=''; PS2=''; PROMPT2=''; ${common}\n`;
|
|
@@ -165,6 +182,7 @@ export async function recordScript(script, { scriptDir, allowFail = false, log =
|
|
|
165
182
|
let onChunk = null; // (data) => void — active step's collector
|
|
166
183
|
let shellDead = false;
|
|
167
184
|
let onExitCb = null;
|
|
185
|
+
let finished = false; // every step recorded — the shell is idle at its prompt
|
|
168
186
|
term.onData(d => { buffer += d; if (onChunk) onChunk(d); });
|
|
169
187
|
term.onExit(() => { shellDead = true; if (onExitCb) onExitCb(); });
|
|
170
188
|
|
|
@@ -217,7 +235,7 @@ export async function recordScript(script, { scriptDir, allowFail = false, log =
|
|
|
217
235
|
// lines while parsing, so nothing is buffered for the command's stdin —
|
|
218
236
|
// interact sends are the only input it can see. The lone `}` line also
|
|
219
237
|
// makes trailing `#` comments in cmd harmless.
|
|
220
|
-
term.write(
|
|
238
|
+
term.write(stepLine(path.basename(shellPath), step.cmd));
|
|
221
239
|
|
|
222
240
|
// interact: watch output, answer prompts (expect/send) — runs alongside
|
|
223
241
|
// the sentinel wait; secrets are sent for real but recorded as ▓▓▓ and
|
|
@@ -225,7 +243,7 @@ export async function recordScript(script, { scriptDir, allowFail = false, log =
|
|
|
225
243
|
const interacts = Array.isArray(step.interact) ? step.interact : [];
|
|
226
244
|
const inputs = [];
|
|
227
245
|
const stepRedactions = [];
|
|
228
|
-
let interactState = { done: interacts.length === 0, error: null, pending: null, cancelled: false };
|
|
246
|
+
let interactState = { done: interacts.length === 0, error: null, pending: null, cancelled: false, interrupted: false };
|
|
229
247
|
if (interacts.length) {
|
|
230
248
|
(async () => {
|
|
231
249
|
let searchFrom = 0;
|
|
@@ -249,6 +267,7 @@ export async function recordScript(script, { scriptDir, allowFail = false, log =
|
|
|
249
267
|
display = text;
|
|
250
268
|
}
|
|
251
269
|
inputs.push([round3(Number(process.hrtime.bigint() - t0) / 1e9), display]);
|
|
270
|
+
if (text.includes('\x03')) interactState.interrupted = true;
|
|
252
271
|
term.write(text);
|
|
253
272
|
interactState.pending = null;
|
|
254
273
|
}
|
|
@@ -310,14 +329,31 @@ export async function recordScript(script, { scriptDir, allowFail = false, log =
|
|
|
310
329
|
...(inClamped.length ? { input: inClamped } : {}),
|
|
311
330
|
});
|
|
312
331
|
log(` ✓ ${step.cmd} (exit ${exit}, ${duration.toFixed(2)}s)`);
|
|
313
|
-
|
|
332
|
+
// 130 is how a command ends when the script itself pressed Ctrl-C:
|
|
333
|
+
// that is the step working (a server stopped), not failing
|
|
334
|
+
if (exit !== 0 && !(exit === 130 && interactState.interrupted) && !allowFail) {
|
|
314
335
|
throw new Error(`step ${idx + 1} exited ${exit}: ${step.cmd} (use --allow-fail to record failures as content)`);
|
|
315
336
|
}
|
|
316
337
|
}
|
|
338
|
+
finished = true;
|
|
317
339
|
return steps;
|
|
318
340
|
} finally {
|
|
319
|
-
|
|
320
|
-
|
|
341
|
+
// A run that completed leaves the shell at its prompt, where `exit` ends
|
|
342
|
+
// it in a few milliseconds. A run that bailed mid-step (a timeout, an
|
|
343
|
+
// abort) leaves that command in the foreground, where `exit` would only
|
|
344
|
+
// queue behind it until the cap below gave up — so that shell is hung up
|
|
345
|
+
// on directly, which takes its foreground job with it.
|
|
346
|
+
if (finished) { try { term.write('exit\n'); } catch { /* already dead */ } }
|
|
347
|
+
else { try { term.kill(); } catch { /* already dead */ } }
|
|
348
|
+
// The cap is a fallback, so it must not outlive the exit it guards: a
|
|
349
|
+
// pending timer keeps the event loop alive, and this one held every
|
|
350
|
+
// recording open for its full 1.5s after the shell had already gone —
|
|
351
|
+
// ~1.5s per `rec` on a 100ms recording, and the bulk of test/cast.test.mjs.
|
|
352
|
+
await new Promise(res => {
|
|
353
|
+
if (shellDead) return res();
|
|
354
|
+
const cap = setTimeout(res, 1500);
|
|
355
|
+
onExitCb = () => { clearTimeout(cap); res(); };
|
|
356
|
+
});
|
|
321
357
|
try { term.kill(); } catch { /* already dead */ }
|
|
322
358
|
}
|
|
323
359
|
}
|
|
@@ -457,12 +493,12 @@ async function refresh(targets, { allowFail }) {
|
|
|
457
493
|
// --------------------------------------------------------------------- main
|
|
458
494
|
|
|
459
495
|
const HELP = `decklight cast — record terminal casts for Decklight decks
|
|
460
|
-
(recording your VOICE narrating a deck is a different command: decklight
|
|
496
|
+
(recording your VOICE narrating a deck is a different command: decklight narrate --mic)
|
|
461
497
|
|
|
462
498
|
Usage:
|
|
463
499
|
decklight cast <script.term.yaml> [-o out.cast.json] [--allow-fail] [--quiet]
|
|
464
|
-
decklight refresh <dir | cast.json…> [--allow-fail]
|
|
465
|
-
decklight export <cast.json> [-o out.cast]
|
|
500
|
+
decklight cast refresh <dir | cast.json…> [--allow-fail]
|
|
501
|
+
decklight cast export <cast.json> [-o out.cast] # asciicast v2
|
|
466
502
|
|
|
467
503
|
Script format (YAML):
|
|
468
504
|
shell: zsh # default: $SHELL (rc files are skipped: zsh -f / bash --norc)
|
|
@@ -496,9 +532,9 @@ Notes:
|
|
|
496
532
|
that step's output and are stored as ▓▓▓ in the cast's input record. Prefer the
|
|
497
533
|
$ENV form — a literal secret is scrubbed from the embedded script, which makes
|
|
498
534
|
that cast non-refreshable.
|
|
499
|
-
•
|
|
500
|
-
• export writes asciicast v2 for the asciinema ecosystem — e.g. a GIF for docs:
|
|
501
|
-
decklight export demo.cast.json && agg demo.cast demo.gif
|
|
535
|
+
• cast refresh re-executes the script embedded in each cast and rewrites on drift.
|
|
536
|
+
• cast export writes asciicast v2 for the asciinema ecosystem — e.g. a GIF for docs:
|
|
537
|
+
decklight cast export demo.cast.json && agg demo.cast demo.gif
|
|
502
538
|
`;
|
|
503
539
|
|
|
504
540
|
export async function castMain(argv = process.argv.slice(2)) {
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The quick fixes Check deck… offers for what `decklight check` finds (SPEC
|
|
6
|
+
* PRESENTING_EDITING). Pure over the deck's text and the resolved design
|
|
7
|
+
* systems: nothing here writes, spawns or reads the clock. The edit server's
|
|
8
|
+
* `GET /deck/edit/check` runs `quickFixes` over the static findings so every
|
|
9
|
+
* row the panel shows carries what pressing its fix WOULD do, and its
|
|
10
|
+
* `POST /deck/edit/check/fix` applies the transforms below.
|
|
11
|
+
*
|
|
12
|
+
* Two kinds of fix (the issue's distinction, #889). A DETERMINISTIC one is a
|
|
13
|
+
* rename or a setting the server can apply itself, in one write:
|
|
14
|
+
*
|
|
15
|
+
* ds-behind migrate design-system migrate (DESIGN_SYSTEM_MIGRATIONS)
|
|
16
|
+
* theme-off-brand theme the theme the brand's migration renames it to,
|
|
17
|
+
* else the brand's first theme
|
|
18
|
+
* off-role rename a renamed role → its successor, on that slide
|
|
19
|
+
* (batchable: ⇧F does every slide at once)
|
|
20
|
+
* ds-unresolved update marketplace update <marketplace>
|
|
21
|
+
* ds-unknown-system add design-system add <name>@<marketplace>, when a
|
|
22
|
+
* registered marketplace offers one of that name
|
|
23
|
+
*
|
|
24
|
+
* Everything else — clipped and crowded slides, ⟨CLICK⟩s against builds, a
|
|
25
|
+
* literal off the palette, a slot left empty — is a JUDGEMENT fix: the panel
|
|
26
|
+
* hands it to the A agent as an ordinary ask (src/core/deckcheck.js writes
|
|
27
|
+
* that prompt, since the live page has findings of its own), and nothing
|
|
28
|
+
* here claims one.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import { deckDesignSystems } from './check.mjs';
|
|
32
|
+
import { configBlock } from './runtime-link.mjs';
|
|
33
|
+
import { deckBehind, designSystemRefs, marketplaceDesignSystems, planMigration } from './design-system-refs.mjs';
|
|
34
|
+
import { configHome, loadRegistry } from './marketplace.mjs';
|
|
35
|
+
import { applyRenames, composeRenames, findRenamed, migrationsOf } from '../tools/design-system-migrations.mjs';
|
|
36
|
+
import { tokenPrefixOf } from '../tools/design-system-format.mjs';
|
|
37
|
+
import { locateSlide, sectionBodies } from '../tools/deck-html.mjs';
|
|
38
|
+
|
|
39
|
+
/** The rules whose fix is deterministic and safe to apply to every slide at once. */
|
|
40
|
+
export const BATCH_RULES = ['off-role'];
|
|
41
|
+
|
|
42
|
+
const readConfig = (html) => { try { return JSON.parse(configBlock(html)?.inner ?? 'null') ?? {}; } catch { return {}; } };
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The role renames every design system the deck uses declares, composed
|
|
46
|
+
* across its migrations: `[{ prefix, roles }]`. ALL its migrations, not
|
|
47
|
+
* only the pending ones: an off-role that still meets a renamed role is a
|
|
48
|
+
* deck recorded at the current version with an old name left in it, which
|
|
49
|
+
* is exactly the case `ds-behind` does not cover (SPEC
|
|
50
|
+
* DESIGN_SYSTEM_MIGRATIONS).
|
|
51
|
+
*/
|
|
52
|
+
function roleRenames(systems) {
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const sys of systems.values()) {
|
|
55
|
+
const mm = sys.migrationManifest;
|
|
56
|
+
if (!mm) continue;
|
|
57
|
+
const roles = composeRenames(migrationsOf(mm)).roles;
|
|
58
|
+
if (Object.keys(roles).length) out.push({ prefix: tokenPrefixOf(mm), roles });
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The renamed roles slide `n` still uses, as `findRenamed` names them. */
|
|
64
|
+
function renamedRolesOn(html, n, systems) {
|
|
65
|
+
const body = sectionBodies(html)[n - 1];
|
|
66
|
+
if (!body) return [];
|
|
67
|
+
return roleRenames(systems).flatMap(({ prefix, roles }) => findRenamed([body], { roles }, prefix));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The theme a deck held to its brand should wear instead of the off-brand
|
|
72
|
+
* one its configuration names (SPEC BRAND_PALETTE): the one a design
|
|
73
|
+
* system's migration renames it to, when that is a brand theme, else the
|
|
74
|
+
* brand's first theme, which is what the runtime opens on. Null when the
|
|
75
|
+
* deck is not off its brand or the brand has no themes.
|
|
76
|
+
*/
|
|
77
|
+
export function offBrandTarget(html, systems = deckDesignSystems(html)) {
|
|
78
|
+
const config = readConfig(html);
|
|
79
|
+
if (config.brandThemesOnly === false || typeof config.theme !== 'string' || !config.theme) return null;
|
|
80
|
+
const brand = [...systems.values()].flatMap((sys) => sys.themeNames ?? []);
|
|
81
|
+
if (!brand.length || brand.includes(config.theme)) return null;
|
|
82
|
+
for (const sys of systems.values()) {
|
|
83
|
+
const mm = sys.migrationManifest;
|
|
84
|
+
const to = mm ? composeRenames(migrationsOf(mm)).themes[config.theme]?.to : null;
|
|
85
|
+
if (to && brand.includes(to)) return { from: config.theme, to, renamed: true };
|
|
86
|
+
}
|
|
87
|
+
return { from: config.theme, to: brand[0], renamed: false };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A renamed role moved to its successor on slide `n`, or on every slide
|
|
92
|
+
* (`n` null): `{ html, count, slides }`, the markup otherwise byte for byte.
|
|
93
|
+
* The head and the tail are never touched — a role a stylesheet writes is
|
|
94
|
+
* the migration's, not a slide's.
|
|
95
|
+
*/
|
|
96
|
+
export function renameRoles(html, n, systems = deckDesignSystems(html)) {
|
|
97
|
+
const renames = roleRenames(systems);
|
|
98
|
+
const total = sectionBodies(html).length;
|
|
99
|
+
const targets = n ? [n] : Array.from({ length: total }, (_, i) => i + 1);
|
|
100
|
+
let out = html;
|
|
101
|
+
let count = 0;
|
|
102
|
+
const slides = [];
|
|
103
|
+
for (const slide of targets) {
|
|
104
|
+
if (slide < 1 || slide > total) continue;
|
|
105
|
+
const { parts, idx } = locateSlide(out, slide);
|
|
106
|
+
let body = parts[idx];
|
|
107
|
+
let here = 0;
|
|
108
|
+
for (const { prefix, roles } of renames) {
|
|
109
|
+
const r = applyRenames(body, { roles }, prefix);
|
|
110
|
+
body = r.text;
|
|
111
|
+
here += r.count;
|
|
112
|
+
}
|
|
113
|
+
if (!here) continue;
|
|
114
|
+
parts[idx] = body;
|
|
115
|
+
out = parts.join('');
|
|
116
|
+
count += here;
|
|
117
|
+
slides.push(slide);
|
|
118
|
+
}
|
|
119
|
+
return { html: out, count, slides };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** `name@marketplace` → its marketplace, when the reference is spelled so. */
|
|
123
|
+
const marketplaceOf = (ref) => /^[^@\s]+@([\w-]+)$/.exec(String(ref ?? ''))?.[1] ?? null;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The static findings, each with the deterministic fix the server can apply
|
|
127
|
+
* for it (`fix: { kind, label, … }`) — or none, which the panel says in so
|
|
128
|
+
* many words. `label` is what the fix WILL do, written on the row (*Migrate
|
|
129
|
+
* to acme 3.0.0 · 3 renames*), never a verb alone.
|
|
130
|
+
*/
|
|
131
|
+
export function quickFixes(findings, html, dir, { home = configHome(), deck = 'deck.html', systems = null } = {}) {
|
|
132
|
+
const sys = systems ?? (designSystemRefs(html).length ? deckDesignSystems(html) : new Map());
|
|
133
|
+
let behind = null;
|
|
134
|
+
let offered = null;
|
|
135
|
+
const registered = () => { try { return Object.keys(loadRegistry(home).marketplaces ?? {}); } catch { return []; } };
|
|
136
|
+
const fixFor = (f) => {
|
|
137
|
+
switch (f.rule) {
|
|
138
|
+
case 'ds-behind': {
|
|
139
|
+
behind ??= deckBehind(html, dir, home, { deck });
|
|
140
|
+
const b = behind.find((x) => f.message.startsWith(`${x.ref} `)) ?? behind[0];
|
|
141
|
+
if (!b) return null;
|
|
142
|
+
const plan = planMigration(html, dir, b.ref, home);
|
|
143
|
+
if (plan.error || !plan.changed) return null;
|
|
144
|
+
return {
|
|
145
|
+
kind: 'migrate', ref: b.ref,
|
|
146
|
+
label: `Migrate to ${plan.name} ${plan.version}${plan.renamed ? ` · ${plan.renamed} rename${plan.renamed === 1 ? '' : 's'}` : ''}`,
|
|
147
|
+
...(b.skills.length ? { skills: b.skills } : {}),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
case 'theme-off-brand': {
|
|
151
|
+
const t = offBrandTarget(html, sys);
|
|
152
|
+
return t ? { kind: 'theme', theme: t.to, label: `Switch to ${t.to}${t.renamed ? ` (${t.from} was renamed)` : ', the brand’s first theme'}` } : null;
|
|
153
|
+
}
|
|
154
|
+
case 'off-role': {
|
|
155
|
+
if (!f.slide) return null;
|
|
156
|
+
const found = renamedRolesOn(html, f.slide, sys);
|
|
157
|
+
if (!found.length) return null;
|
|
158
|
+
return {
|
|
159
|
+
kind: 'rename', slide: f.slide, batch: true,
|
|
160
|
+
label: `Rename ${found.length === 1 ? `${found[0].from} → ${found[0].to}` : `${found.length} roles to their successors`} on slide ${f.slide}`,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
case 'ds-unresolved': {
|
|
164
|
+
const ref = /^design system (\S+) cannot be read/.exec(f.message)?.[1];
|
|
165
|
+
const name = marketplaceOf(ref);
|
|
166
|
+
if (!name || !registered().includes(name)) return null;
|
|
167
|
+
return { kind: 'marketplace-update', name, label: `Update the ${name} marketplace` };
|
|
168
|
+
}
|
|
169
|
+
case 'ds-unknown-system': {
|
|
170
|
+
const want = /no design system called "([^"]+)"/.exec(f.message)?.[1];
|
|
171
|
+
if (!want) return null;
|
|
172
|
+
offered ??= marketplaceDesignSystems(home).systems;
|
|
173
|
+
const hit = offered.find((s) => s.name === want && !s.missing);
|
|
174
|
+
return hit ? { kind: 'design-system-add', ref: hit.qualified, label: `Add ${hit.qualified} to the deck` } : null;
|
|
175
|
+
}
|
|
176
|
+
default: return null;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
return findings.map((f) => {
|
|
180
|
+
const fix = fixFor(f);
|
|
181
|
+
return fix ? { ...f, fix } : f;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** `fix: <rule> on slide N`, or `fix: <rule>` for the deck — the commit a quick fix makes. */
|
|
186
|
+
export const fixSubject = (rule, slide = null) => `fix: ${rule}${slide ? ` on slide ${slide}` : ''}`;
|