decklight 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/PLATFORM.md +44 -3
  2. package/README.md +7 -5
  3. package/SPEC.md +100 -31
  4. package/cli/agent-review.mjs +5 -4
  5. package/cli/agents.mjs +11 -5
  6. package/cli/bundle-audio.mjs +10 -3
  7. package/cli/bundle-module.mjs +95 -0
  8. package/cli/bundle.mjs +58 -6
  9. package/cli/cast.mjs +41 -5
  10. package/cli/check-fixes.mjs +186 -0
  11. package/cli/check.mjs +32 -5
  12. package/cli/commit-flow.mjs +7 -3
  13. package/cli/commit-message.mjs +1 -1
  14. package/cli/commit-split.mjs +2 -2
  15. package/cli/deck-refs.mjs +8 -3
  16. package/cli/design-system-refs.mjs +263 -6
  17. package/cli/design-system.mjs +82 -14
  18. package/cli/edit-git.mjs +2 -2
  19. package/cli/edit-handover.mjs +129 -23
  20. package/cli/edit-look.mjs +248 -5
  21. package/cli/edit.mjs +504 -58
  22. package/cli/enhance.mjs +12 -10
  23. package/cli/git.mjs +13 -0
  24. package/cli/init.mjs +8 -3
  25. package/cli/marketplace-autocheck.mjs +200 -0
  26. package/cli/marketplace.mjs +250 -13
  27. package/cli/narrate.mjs +78 -3
  28. package/cli/open.mjs +24 -6
  29. package/cli/pdf.mjs +27 -8
  30. package/cli/pptx-export.mjs +7 -4
  31. package/cli/record.mjs +73 -13
  32. package/cli/remote.mjs +32 -6
  33. package/cli/serve.mjs +2 -2
  34. package/cli/skill-content.mjs +40 -3
  35. package/cli/skills.mjs +247 -3
  36. package/cli/theme-refs.mjs +14 -2
  37. package/cli/units.mjs +75 -7
  38. package/dist/build-info.json +1 -1
  39. package/dist/decklight.css +429 -32
  40. package/dist/decklight.js +169 -123
  41. package/dist/decklight.js.map +4 -4
  42. package/package.json +1 -1
  43. package/tools/design-system-format.mjs +25 -0
  44. package/tools/design-system-migrations.mjs +207 -0
  45. package/tools/exec.mjs +10 -2
  46. package/tools/narration-manifest.mjs +77 -3
  47. package/tools/site-clip.mjs +114 -0
  48. package/tools/video.mjs +69 -6
@@ -7,6 +7,8 @@
7
7
  // decklight marketplace add <owner/repo | git url | path> [--name x]
8
8
  // decklight marketplace list
9
9
  // decklight marketplace update <name> [--branch <ref>]
10
+ // decklight marketplace outdated [<name>] [--json]
11
+ // decklight marketplace auto-check [on|off]
10
12
  // decklight marketplace remove <name>
11
13
  //
12
14
  // A marketplace is a git repo (or a local directory) with
@@ -25,8 +27,9 @@
25
27
  // offered them.
26
28
  //
27
29
  // The invariant this module exists to keep (SPEC MARKETPLACE_REGISTRY): the
28
- // network is touched ONLY by an explicit `add` or `update` of a remote
29
- // source. Registering is a filesystem write; `list` reads only the cache;
30
+ // network is touched ONLY by an explicit `add`, `update` or `outdated` of a
31
+ // remote source — and `outdated` only asks where a ref points (`git
32
+ // ls-remote`), it fetches no file. Registering is a filesystem write; `list` reads only the cache;
30
33
  // installing an entry reads the checkout; nothing on the deck-load or
31
34
  // presenting path imports this module at all. A deck on conference wifi, on a
32
35
  // plane, or air-gapped behaves identically to one at a desk, marketplace or
@@ -35,7 +38,7 @@
35
38
  import {
36
39
  existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, statSync, writeFileSync,
37
40
  } from 'node:fs';
38
- import { execFileSync } from 'node:child_process';
41
+ import { execFile, execFileSync } from 'node:child_process';
39
42
  // The registry is the file that says which marketplaces exist at all. A
40
43
  // truncate interrupted halfway leaves JSON that no longer parses, and
41
44
  // loadRegistry rightly refuses to guess at it — so the write is a rename.
@@ -663,6 +666,48 @@ export function classifySource(spec, { exists = existsSync } = {}) {
663
666
  return { kind: 'local', root: resolve(spec), spec };
664
667
  }
665
668
 
669
+ /**
670
+ * What `add <spec>` is about to do, said before it does it — the in-deck door's
671
+ * first ⏎ (SPEC DESIGN_SYSTEMS). Touches no network: it classifies the spec,
672
+ * and for a local directory checks that the manifest is there, since that much
673
+ * is free and saying it now beats saying it after a second ⏎.
674
+ *
675
+ * `base` is the directory a relative path is read against: the deck's, for
676
+ * the door, where the CLI uses its cwd. A local spec comes back ABSOLUTE in
677
+ * `spec`, because the registry keeps the source as given and a relative one
678
+ * would mean something else from the next directory `update` runs in.
679
+ * `registered` names the marketplace already registered from that source, if
680
+ * any: adding it again re-clones it, as `add` does at the command line.
681
+ * `ref` is `--branch`: held to the same rule as the command line's, and
682
+ * refused on a local directory now rather than after the second ⏎.
683
+ */
684
+ export function planAdd(rawSpec, { ref = null, base = process.cwd(), home = configHome(), exists = existsSync } = {}) {
685
+ const raw = String(rawSpec ?? '').trim();
686
+ if (!raw) throw new MarketplaceError('needs an owner/repo, a git url, or a path');
687
+ const bad = ref === null ? null : refProblem(String(ref));
688
+ if (bad) throw new MarketplaceError(`--branch ${JSON.stringify(String(ref))} ${bad}`);
689
+ // it becomes one argument of `decklight marketplace add`: never an option,
690
+ // never more than one line
691
+ if (raw.startsWith('-') || /[\u0000-\u001f\u007f]/.test(raw) || raw.length > 2048) {
692
+ throw new MarketplaceError(`${JSON.stringify(raw.slice(0, 80))} is not an owner/repo, a git url, or a path`);
693
+ }
694
+ const src = classifySource(raw, { exists: (p) => exists(resolve(base, p)) });
695
+ let spec = raw, does;
696
+ if (src.kind === 'local') {
697
+ const root = resolve(base, raw);
698
+ if (!exists(root)) throw new MarketplaceError(`no such directory: ${root}`);
699
+ if (!exists(join(root, MANIFEST_PATH))) throw new MarketplaceError(`${root} has no ${MANIFEST_PATH} — is it a marketplace?`);
700
+ if (ref) throw new MarketplaceError(`${raw} is a local directory — --branch needs a repository to clone`);
701
+ spec = root;
702
+ does = `register ${root} — read in place, nothing is fetched`;
703
+ } else {
704
+ does = `clone ${cloneUrl(src)}${ref ? ` at ${ref}` : ''} with your git credentials on this machine`;
705
+ }
706
+ const reg = loadRegistry(home).marketplaces ?? {};
707
+ const registered = Object.keys(reg).find((n) => reg[n].source === spec) ?? null;
708
+ return { spec, ref: ref ?? null, kind: src.kind, url: src.kind === 'local' ? null : cloneUrl(src), path: src.kind === 'local' ? spec : null, does, registered };
709
+ }
710
+
666
711
  /** The URL git is handed for a remote source. */
667
712
  export const cloneUrl = (src) =>
668
713
  (src.kind === 'github' ? `https://github.com/${src.owner}/${src.repo}.git` : src.url);
@@ -940,9 +985,131 @@ export function resolveEntry(ref, catalogs) {
940
985
  return hits[0];
941
986
  }
942
987
 
988
+ // ── what changed, and what is behind ──────────────────────────────────────
989
+
990
+ const entryKey = (e) => `${e.type}:${e.name}`;
991
+
992
+ /**
993
+ * What one fetch of a catalog changed against the copy it replaced: entries
994
+ * `added` and `removed`, and entries whose `version` moved (`changed`, with
995
+ * `from` and `to`). `before` is null for a first fetch, when everything is
996
+ * new — said as `first`, so a reader does not call forty entries "news".
997
+ * Pure: two entry lists in, one record out.
998
+ */
999
+ export function catalogChanges(before, after) {
1000
+ const was = new Map((before ?? []).map((e) => [entryKey(e), e]));
1001
+ const now = new Map((after ?? []).map((e) => [entryKey(e), e]));
1002
+ const brief = (e) => ({ type: e.type, name: e.name, version: e.version ?? null });
1003
+ const added = [...now.values()].filter((e) => !was.has(entryKey(e))).map(brief);
1004
+ const removed = [...was.values()].filter((e) => !now.has(entryKey(e))).map(brief);
1005
+ const changed = [...now.values()]
1006
+ .filter((e) => was.has(entryKey(e)) && (was.get(entryKey(e)).version ?? null) !== (e.version ?? null))
1007
+ .map((e) => ({ type: e.type, name: e.name, from: was.get(entryKey(e)).version ?? null, to: e.version ?? null }));
1008
+ const order = (a, b) => a.type.localeCompare(b.type) || a.name.localeCompare(b.name);
1009
+ return { first: before === null, added: added.sort(order), removed: removed.sort(order), changed: changed.sort(order) };
1010
+ }
1011
+
1012
+ /**
1013
+ * Remember what a fetch changed on the marketplace's registry record, so the
1014
+ * "what's new" of its last update can be read again later — by `list`, by the
1015
+ * Marketplaces… screen — and not only in the moment it was printed.
1016
+ */
1017
+ function noteChanges(record, beforeCat, afterManifest, { from = null, to = null, now = Date.now() } = {}) {
1018
+ const before = beforeCat?.ok ? beforeCat.manifest.entries : null;
1019
+ record.changes = { at: new Date(now).toISOString(), from: from ?? null, to: to ?? null, ...catalogChanges(before, afterManifest.entries) };
1020
+ return record.changes;
1021
+ }
1022
+
1023
+ /** The what's-new lines `update` prints: `+ new`, `− gone`, `↑ moved`. */
1024
+ function changeLines(name, c) {
1025
+ return [
1026
+ ...c.added.map((e) => `+ ${e.name}@${name}${e.version ? ` ${e.version}` : ''} (${e.type})`),
1027
+ ...c.removed.map((e) => `− ${e.name}@${name} (${e.type}) — no longer offered`),
1028
+ ...c.changed.map((e) => `↑ ${e.name}@${name} ${e.from ?? 'unversioned'} → ${e.to ?? 'unversioned'}`),
1029
+ ];
1030
+ }
1031
+
1032
+ /** `git ls-remote`, asynchronously: several marketplaces are asked at once. */
1033
+ const lsRemote = (url, patterns, { timeoutMs }) => new Promise((done, fail) => {
1034
+ execFile('git', ['ls-remote', '--', url, ...patterns], {
1035
+ encoding: 'utf8', timeout: timeoutMs,
1036
+ // never a password prompt, as for a clone: an unreachable repo is an answer
1037
+ env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
1038
+ }, (err, stdout, stderr) => (err ? fail(Object.assign(err, { stderr })) : done(stdout)));
1039
+ });
1040
+
1041
+ /**
1042
+ * The commit `ref` names in an `ls-remote` answer — the one `clone --branch`
1043
+ * would check out: a branch before a tag of the same name, and a tag PEELED
1044
+ * (`^{}`), since an annotated tag's own object is not the commit a clone lands
1045
+ * on. No ref is the remote's `HEAD`, as no `--branch` is.
1046
+ */
1047
+ export function remoteCommit(lsRemoteOut, ref = null) {
1048
+ const rows = String(lsRemoteOut).split('\n').map((l) => l.trim().split(/\s+/))
1049
+ .filter(([sha, name]) => /^[0-9a-f]{40,64}$/.test(sha ?? '') && name);
1050
+ const at = (name) => rows.find(([, n]) => n === name)?.[0] ?? null;
1051
+ if (!ref) return at('HEAD');
1052
+ return at(`refs/heads/${ref}`) ?? at(`refs/tags/${ref}^{}`) ?? at(`refs/tags/${ref}`) ?? at(ref);
1053
+ }
1054
+
1055
+ /**
1056
+ * Is a marketplace behind its source? Asked, never fetched: a remote is asked
1057
+ * where its ref points now (`git ls-remote`, the caller's credentials, no
1058
+ * prompt) and that is held against the commit the cached catalog came from; a
1059
+ * local directory's manifest is compared with the cached copy, with no
1060
+ * network at all. Nothing on disk changes — `update` is what takes it.
1061
+ *
1062
+ * `state` is one of: `current`; `behind` (with `remote`, the commit an update
1063
+ * would bring); `unfetched` (never fetched, so `update` is its first fetch);
1064
+ * `unknown` (fetched before commits were recorded — an update records one);
1065
+ * `unreachable` (with `error`, the reason).
1066
+ */
1067
+ export async function checkMarketplace(name, home = configHome(), { ask = lsRemote, timeoutMs = 15000 } = {}) {
1068
+ const m = loadRegistry(home).marketplaces?.[name];
1069
+ if (!m) throw new MarketplaceError(`no marketplace "${name}" (decklight marketplace list)`);
1070
+ const src = classifySource(m.source);
1071
+ const base = { name, source: m.source, ref: m.ref ?? null, local: src.kind === 'local', commit: m.commit ?? null, remote: null, error: null };
1072
+ if (loadCatalog(name, home) === null) return { ...base, state: 'unfetched' };
1073
+ if (src.kind === 'local') {
1074
+ let raw;
1075
+ try { raw = readFileSync(join(src.root, MANIFEST_PATH), 'utf8'); } catch {
1076
+ return { ...base, state: 'unreachable', error: `${m.source} has no ${MANIFEST_PATH} any more` };
1077
+ }
1078
+ let cached = null;
1079
+ try { cached = readFileSync(cachePath(home, name), 'utf8'); } catch { /* read just above; gone since */ }
1080
+ return { ...base, state: raw === cached ? 'current' : 'behind' };
1081
+ }
1082
+ let out;
1083
+ // a tag's peeled line answers only when asked for by name
1084
+ try { out = await ask(cloneUrl(src), m.ref ? [m.ref, `${m.ref}^{}`] : ['HEAD'], { timeoutMs }); } catch (e) {
1085
+ return { ...base, state: 'unreachable', error: `git ls-remote ${cloneUrl(src)} failed — ${e.killed ? `no answer in ${Math.round(timeoutMs / 1000)}s` : oneline(e)}` };
1086
+ }
1087
+ const remote = remoteCommit(out, m.ref ?? null);
1088
+ if (!remote) return { ...base, state: 'unreachable', error: m.ref ? `no branch or tag "${m.ref}" in ${m.source}` : `${m.source} has no HEAD` };
1089
+ if (!m.commit) return { ...base, remote, state: 'unknown' };
1090
+ return { ...base, remote, state: remote === m.commit ? 'current' : 'behind' };
1091
+ }
1092
+
1093
+ /** `checkMarketplace` for every registered marketplace (or `only` one), asked at once. */
1094
+ export async function checkMarketplaces(home = configHome(), { only = null, ...opts } = {}) {
1095
+ const names = only ? [only] : Object.keys(loadRegistry(home).marketplaces ?? {}).sort();
1096
+ return Promise.all(names.map((n) => checkMarketplace(n, home, opts)));
1097
+ }
1098
+
1099
+ /** One line of `outdated`: the state, and the command that acts on it. */
1100
+ function outdatedLine(r) {
1101
+ const at = (c) => (c ? `@${c.slice(0, 7)}` : '');
1102
+ const fix = ` — decklight marketplace update ${r.name}`;
1103
+ if (r.state === 'current') return `${r.name} up to date${r.commit ? ` ${at(r.commit)}` : ''}`;
1104
+ if (r.state === 'behind') return r.local ? `${r.name} changed on disk${fix}` : `${r.name} behind ${at(r.commit)} → ${at(r.remote)}${fix}`;
1105
+ if (r.state === 'unfetched') return `${r.name} registered, not fetched${fix}`;
1106
+ if (r.state === 'unknown') return `${r.name} no commit recorded to compare (the source is at ${at(r.remote)})${fix}`;
1107
+ return `${r.name} could not ask — ${r.error}`;
1108
+ }
1109
+
943
1110
  // ── the command ────────────────────────────────────────────────────────────
944
1111
 
945
- const USAGE = `usage: decklight marketplace <add|list|update|remove> …
1112
+ const USAGE = `usage: decklight marketplace <add|list|update|outdated|auto-check|remove> …
946
1113
 
947
1114
  decklight marketplace add <owner/repo | git url | path> [--name <name>]
948
1115
  [--branch <ref>]
@@ -971,15 +1138,30 @@ const USAGE = `usage: decklight marketplace <add|list|update|remove> …
971
1138
  re-clone a marketplace, refreshing the cached manifest and the checkout
972
1139
  (at the ref it was added with, unless --branch moves the pin)
973
1140
  its entries install from; for a registered-not-fetched marketplace this is
974
- the FIRST fetch it ever gets. Then it names every entry you installed from
975
- it that the catalog now has newer, and the command that takes it — it
976
- installs nothing itself
1141
+ the FIRST fetch it ever gets. Then it says what's new in the catalog
1142
+ (entries added, gone, or at a new version — remembered, so the
1143
+ Marketplaces… screen shows it again), names every entry you installed
1144
+ from it that the catalog now has newer, and the command that takes it —
1145
+ it installs nothing itself
1146
+
1147
+ decklight marketplace outdated [<name>] [--json]
1148
+ which marketplaces are behind their source: a remote is ASKED where its
1149
+ ref points now (git ls-remote — no clone, nothing written), a local
1150
+ directory's manifest is compared with the cached copy. Each behind one is
1151
+ named with the update that takes it
1152
+
1153
+ decklight marketplace auto-check [on|off]
1154
+ whether an edit server that starts runs outdated by itself, in the
1155
+ background and at most once in 12 hours, and the deck offers to update
1156
+ what it found behind. Off until you turn it on; it only ever offers, an
1157
+ update is still yours. With no argument, says which it is
977
1158
 
978
1159
  decklight marketplace remove <name>
979
1160
  unregister a marketplace and drop its cached manifest and checkout
980
1161
 
981
- registering is not fetching: the network is touched only by an explicit add
982
- or update, never when a deck loads or presents (SPEC MARKETPLACE_REGISTRY).
1162
+ registering is not fetching: the network is touched only by an explicit add,
1163
+ update or outdated (or the auto-check you turned on), never when a deck loads
1164
+ or presents (SPEC MARKETPLACE_REGISTRY).
983
1165
  DECKLIGHT_HOME overrides ~/.decklight/.`;
984
1166
 
985
1167
  const printManifestErrors = (cmd, spec, errors) => {
@@ -1033,6 +1215,8 @@ async function addMain(args, home) {
1033
1215
  reg.marketplaces[name] = {
1034
1216
  ...(existing ?? {}), source: spec, ref: ref ?? undefined, commit: got.commit ?? undefined,
1035
1217
  };
1218
+ // a re-add is a refresh, and says what it changed as `update` does
1219
+ if (existing) noteChanges(reg.marketplaces[name], loadCatalog(name, home), v.manifest, { from: existing.commit, to: got.commit });
1036
1220
  writeCache(home, name, got.raw);
1037
1221
  const at = adoptCheckout(home, name, got.checkout);
1038
1222
  got.checkout = null;
@@ -1068,7 +1252,7 @@ function versionNote(entry, installed) {
1068
1252
  return ` ${had} → ${entry.version}`;
1069
1253
  }
1070
1254
 
1071
- function listMain(home) {
1255
+ async function listMain(home) {
1072
1256
  const installs = loadLedger(home).installs;
1073
1257
  const reg = loadRegistry(home);
1074
1258
  const names = Object.keys(reg.marketplaces).sort();
@@ -1076,6 +1260,7 @@ function listMain(home) {
1076
1260
  console.log('no marketplaces registered — decklight marketplace add <owner/repo | git url | path>');
1077
1261
  return 0;
1078
1262
  }
1263
+ console.log(await autoCheckLine(reg, home));
1079
1264
  for (const name of names) {
1080
1265
  const m = reg.marketplaces[name];
1081
1266
  // The commit is what the manifest AND every entry's files came from — one
@@ -1117,6 +1302,30 @@ function listMain(home) {
1117
1302
  return 0;
1118
1303
  }
1119
1304
 
1305
+ // The auto-check (cli/marketplace-autocheck.mjs) imports this module, so the
1306
+ // commands that use it load it when they run.
1307
+ let autoCheckModule = null;
1308
+ const loadAutoCheck = async () => (autoCheckModule ??= await import('./marketplace-autocheck.mjs'));
1309
+
1310
+ /** Whether an edit server checks for updates as it starts, and what it last found. */
1311
+ async function autoCheckLine(reg, home) {
1312
+ if (reg.autoCheck !== true) return 'auto-check: off — decklight marketplace auto-check on checks for updates when decklight starts';
1313
+ const { readCheckRecord, checkSummary } = await loadAutoCheck();
1314
+ const rec = readCheckRecord(home);
1315
+ return `auto-check: on — ${rec ? checkSummary(rec) : 'not checked yet: the next edit server to start asks'}`;
1316
+ }
1317
+
1318
+ async function autoCheckMain(args, home) {
1319
+ const [want] = args.filter((a) => !a.startsWith('-'));
1320
+ if (want === undefined) { console.log(await autoCheckLine(loadRegistry(home), home)); return 0; }
1321
+ if (want !== 'on' && want !== 'off') { console.error(`decklight marketplace auto-check: on or off, not "${want}"`); return 1; }
1322
+ (await loadAutoCheck()).setAutoCheck(want === 'on', home);
1323
+ console.log(want === 'on'
1324
+ ? 'auto-check: on — an edit server that starts asks each source whether it has moved (nothing is fetched), at most once in 12 hours, and the deck offers what it finds'
1325
+ : 'auto-check: off — nothing is asked until you press C on Marketplaces… or run decklight marketplace outdated');
1326
+ return 0;
1327
+ }
1328
+
1120
1329
  async function updateMain(args, home) {
1121
1330
  const [name] = args.filter((a, i) => !a.startsWith('-') && args[i - 1] !== '--branch');
1122
1331
  if (!name) { console.error(`decklight marketplace update: which one?\n\n${USAGE}`); return 1; }
@@ -1146,6 +1355,7 @@ async function updateMain(args, home) {
1146
1355
  try {
1147
1356
  const v = validateManifest(got.raw);
1148
1357
  if (!v.ok) { printManifestErrors('update', m.source, v.errors); return 1; }
1358
+ const before = loadCatalog(name, home);
1149
1359
  writeCache(home, name, got.raw);
1150
1360
  const at = adoptCheckout(home, name, got.checkout);
1151
1361
  got.checkout = null;
@@ -1154,18 +1364,30 @@ async function updateMain(args, home) {
1154
1364
  reg2.marketplaces[name] = {
1155
1365
  ...reg2.marketplaces[name], ref: ref ?? undefined, commit: got.commit ?? undefined,
1156
1366
  };
1367
+ noteChanges(reg2.marketplaces[name], before, v.manifest, { from: m.commit, to: got.commit });
1157
1368
  saveRegistry(reg2, home);
1158
1369
  }
1370
+ // the last check found this one behind: it no longer is, and nothing offers it
1371
+ (await loadAutoCheck()).noteUpdated(name, got.commit ?? null, home);
1159
1372
  console.log(`${first ? 'fetched' : 'updated'} ${name}${ref ? ` at ${ref}` : ''} — ${entriesSummary(name, v.manifest.entries)}`);
1160
1373
  if (at) console.log(` cloned to ${at}${got.commit ? ` (${got.commit.slice(0, 7)})` : ''}`);
1374
+ // What's new in the CATALOG — the first fetch has no "before" to hold it
1375
+ // against, so it is the entries line above and nothing more.
1376
+ if (!first && before?.ok) {
1377
+ const lines = changeLines(name, catalogChanges(before.manifest.entries, v.manifest.entries));
1378
+ console.log(lines.length ? ` what's new:\n${lines.map((l) => ` ${l}`).join('\n')}` : ' nothing in the catalog changed');
1379
+ }
1161
1380
  // What you installed from it that the catalog now has newer — and the
1162
1381
  // one command that takes each. Nothing is installed here: an update
1163
1382
  // refreshes the catalog, and taking a new version stays your call.
1164
- const newer = newerThanInstalled(home, name);
1383
+ // A design system whose new version declares migrations says what that
1384
+ // means for the decks on it, and what moves them, instead of a re-add.
1385
+ const { withMigrationHint } = await import('./design-system-refs.mjs');
1386
+ const newer = newerThanInstalled(home, name).map((n) => withMigrationHint(n, home));
1165
1387
  if (newer.length) {
1166
1388
  console.log(` newer than what you installed:`);
1167
1389
  for (const n of newer) {
1168
- console.log(` ${n.qualified} ${n.from ?? 'unversioned'} → ${n.to}${n.how ? ` — ${n.how}` : ''}`);
1390
+ console.log(` ${n.qualified} ${n.from ?? 'unversioned'} → ${n.to}${n.note ? ` (${n.note})` : ''}${n.how ? ` — ${n.how}` : ''}`);
1169
1391
  }
1170
1392
  }
1171
1393
  return 0;
@@ -1174,6 +1396,19 @@ async function updateMain(args, home) {
1174
1396
  }
1175
1397
  }
1176
1398
 
1399
+ async function outdatedMain(args, home) {
1400
+ const [name] = args.filter((a) => !a.startsWith('-'));
1401
+ const reg = loadRegistry(home);
1402
+ if (name && !reg.marketplaces[name]) { console.error(`decklight marketplace outdated: no marketplace "${name}" (decklight marketplace list)`); return 1; }
1403
+ const results = await checkMarketplaces(home, { only: name ?? null });
1404
+ // the answer is kept: Marketplaces… starts from it, and the auto-check's window is measured from it
1405
+ (await loadAutoCheck()).recordCheck(results, home, { all: !name });
1406
+ if (args.includes('--json')) { console.log(JSON.stringify({ marketplaces: results }, null, 2)); return 0; }
1407
+ if (!results.length) { console.log('no marketplaces registered — decklight marketplace add <owner/repo | git url | path>'); return 0; }
1408
+ for (const r of results) console.log(outdatedLine(r));
1409
+ return 0;
1410
+ }
1411
+
1177
1412
  function removeMain(args, home) {
1178
1413
  const [name] = args.filter((a) => !a.startsWith('-'));
1179
1414
  if (!name) { console.error(`decklight marketplace remove: which one?\n\n${USAGE}`); return 1; }
@@ -1197,9 +1432,11 @@ export async function marketplaceMain(args = []) {
1197
1432
  const home = configHome();
1198
1433
  try {
1199
1434
  if (sub === 'add') return await addMain(rest, home);
1200
- if (sub === 'list') return listMain(home);
1435
+ if (sub === 'list') return await listMain(home);
1201
1436
  if (sub === 'update') return await updateMain(rest, home);
1437
+ if (sub === 'outdated') return await outdatedMain(rest, home);
1202
1438
  if (sub === 'remove') return removeMain(rest, home);
1439
+ if (sub === 'auto-check') return await autoCheckMain(rest, home);
1203
1440
  } catch (e) {
1204
1441
  if (e instanceof MarketplaceError) { console.error(`decklight marketplace ${sub}: ${e.message}`); return 1; }
1205
1442
  throw e;
package/cli/narrate.mjs CHANGED
@@ -5,7 +5,7 @@
5
5
  * decklight narrate — put the deck's narration into a folder beside it.
6
6
  *
7
7
  * decklight narrate <deck.html> [--engine E] [--voice V] [--format F] [--slides a-b] [--dir NAME]
8
- * decklight narrate <deck.html> --mic [--slides a-b] [--dir NAME] [--port N] [--no-open]
8
+ * decklight narrate <deck.html> --mic [--slides a-b] [--dir NAME] [--port N] [--remote] [--no-open]
9
9
  * decklight narrate <deck.html> --face [--video] [--dir NAME]
10
10
  *
11
11
  * One command for the two ways a deck gets a recorded voice: an engine reads
@@ -39,7 +39,7 @@ const VOICEOVER = fileURLToPath(new URL('../tools/voiceover.mjs', import.meta.ur
39
39
  const LIPSYNC = fileURLToPath(new URL('../tools/lipsync.mjs', import.meta.url));
40
40
  // the flags either side takes a value for, so the deck is found past them
41
41
  const VALUE_FLAGS = new Set(['-o', '--dir', '--engine', '--voice', '--style', '--data-dir', '--project',
42
- '--format', '--slides', '--port', '--model', '--lang', '--location', '--tts-format', '--tts-stability',
42
+ '--format', '--slides', '--beats', '--countdown', '--takes', '--port', '--model', '--lang', '--location', '--tts-format', '--tts-stability',
43
43
  '--rhubarb', '--portrait', '--python', '--wav2lip-dir', '--wav2lip-ckpt', '--sadtalker-dir',
44
44
  '--veo-project', '--veo-location', '--veo-model', '--veo-seconds', '--veo-prompt', '--veo-face-y']);
45
45
 
@@ -59,12 +59,18 @@ export const USAGE = `usage: decklight narrate <deck.html> [--mic] [--slides a-b
59
59
  --mic serves the deck on http://127.0.0.1 (a microphone needs it) and
60
60
  opens it with the recorder up; → ends a beat and reveals the
61
61
  next build, so your voice paces the deck as it will be presented
62
+ --beats k-l with --slides N: only these beats of slide N; the others are kept
63
+ --takes slide|beat one take per slide (→ cuts a beat and keeps going), or per beat
64
+ --countdown N seconds of count-in before each take, 0 for none
65
+ --remote the phone remote too: its next ends a beat, its retake redoes one,
66
+ so no keystroke gets into the take
62
67
  --port N, --no-open
63
68
  EXAMPLE: decklight narrate talk.html --mic
64
69
 
65
70
  either way, an engine or the microphone
66
71
  --slides a-b only these slides; every other slide's files are left alone
67
- --dir NAME the folder, relative to the deck [its narration.files, else voiceover]
72
+ --dir NAME the folder, relative to the deck
73
+ [an engine: its narration.files, else voiceover · --mic: voices/me]
68
74
 
69
75
  the character mouths what is already there (--face)
70
76
  --face lip-sync for every slide and [click] beat in the folder, which the
@@ -75,6 +81,14 @@ export const USAGE = `usage: decklight narrate <deck.html> [--mic] [--slides a-b
75
81
  --dir NAME only this folder [every one the deck's narration.files names]
76
82
  EXAMPLE: decklight narrate talk.html --face
77
83
 
84
+ is the narration still the notes? (--check)
85
+ --check every track beside the deck, slide by slide: in step, the words
86
+ changed, or (your own voice) only the [click] split moved, which
87
+ a recording cannot follow; each with the command that fixes it.
88
+ Exits 1 when something is out of step
89
+ --dir NAME only this folder
90
+ EXAMPLE: decklight narrate talk.html --check
91
+
78
92
  the deck plays the folder back with
79
93
  narration: { files: '<dir>', segments: true } (wav: ext: 'wav')
80
94
  `;
@@ -151,6 +165,60 @@ function faceMain(plan, argv) {
151
165
  return 0;
152
166
  }
153
167
 
168
+ /**
169
+ * The track folders beside a deck that carry a manifest: the same two levels
170
+ * the edit server's track list walks (`voices/<voice>`), relative to the deck.
171
+ */
172
+ export function manifestTracks(deckDir) {
173
+ const out = [];
174
+ const look = (rel) => {
175
+ let entries;
176
+ try { entries = readdirSync(join(deckDir, rel), { withFileTypes: true }); } catch { return []; }
177
+ if (entries.some((e) => e.isFile() && e.name === 'manifest.json')) out.push(rel);
178
+ return entries.filter((e) => e.isDirectory() && !e.name.startsWith('.') && e.name !== 'node_modules');
179
+ };
180
+ for (const e of look('.')) {
181
+ for (const k of look(e.name)) look(`${e.name}/${k.name}`);
182
+ }
183
+ return out.filter((d) => d !== '.');
184
+ }
185
+
186
+ /**
187
+ * `--check` (#850): each track against the deck's notes, said per slide, with
188
+ * the re-record line. A track recorded by hand before a manifest existed has
189
+ * nothing to compare and is named as unchecked rather than passed.
190
+ */
191
+ async function checkMain(plan, argv) {
192
+ if (!plan.deck || !existsSync(plan.deck)) { console.error(`decklight narrate: ${plan.deck ? `no deck at ${plan.deck}` : 'name the deck'}`); return 1; }
193
+ const { trackDrift, rerecordLine } = await import('../tools/narration-manifest.mjs');
194
+ const html = readFileSync(plan.deck, 'utf8');
195
+ const deckDir = dirname(resolve(plan.deck));
196
+ const dirAt = argv.indexOf('--dir');
197
+ const dirs = dirAt === -1 ? manifestTracks(deckDir) : [argv[dirAt + 1]];
198
+ let out = 0;
199
+ if (!dirs.length) { console.log('no narration track with a manifest beside this deck — nothing to check'); return 0; }
200
+ for (const dir of dirs) {
201
+ let m = null;
202
+ try { m = JSON.parse(readFileSync(join(deckDir, dir, 'manifest.json'), 'utf8')); } catch { /* reported below */ }
203
+ if (!Array.isArray(m?.slides)) { console.log(`${dir}/ no manifest: recorded before decklight kept one, not checked`); continue; }
204
+ const mine = m.recorder === 'mic';
205
+ const who = mine ? 'your voice' : [m.voice, m.engine].filter(Boolean).join(' · ') || 'recorded';
206
+ const { drift, unknown } = trackDrift(m, html);
207
+ const note = unknown ? ` (${unknown} slide${unknown === 1 ? '' : 's'} recorded before the script was kept: not checked)` : '';
208
+ if (!drift.length) { console.log(`${dir}/ ${who}: in step with the notes${note}`); continue; }
209
+ out = 1;
210
+ console.log(`${dir}/ ${who}: ${drift.length} slide${drift.length === 1 ? '' : 's'} out of step${note}`);
211
+ for (const d of drift) {
212
+ console.log(d.why === 'clicks'
213
+ ? ` slide ${d.slide}: the [click] split moved${d.was !== d.now ? ` (${d.was} beats → ${d.now})` : ''}, the words did not`
214
+ + (mine ? ' — a recorded beat is cut where you pressed →, so the marker alone cannot move a build' : '')
215
+ : ` slide ${d.slide}: the notes changed since it was recorded`);
216
+ console.log(` ${rerecordLine(plan.deck, dir, [d.slide], { mine })}`);
217
+ }
218
+ }
219
+ return out;
220
+ }
221
+
154
222
  export async function narrateMain(argv = []) {
155
223
  const wantsHelp = argv.includes('--help') || argv.includes('-h');
156
224
  if (!argv.length || (wantsHelp && !argv.includes('--engine') && !argv.includes('--mic'))) {
@@ -158,10 +226,17 @@ export async function narrateMain(argv = []) {
158
226
  return argv.length ? 0 : 1;
159
227
  }
160
228
  const plan = narratePlan(argv);
229
+ if (argv.includes('--check')) return checkMain(plan, argv);
161
230
  if (argv.includes('--face')) return faceMain(plan, argv);
162
231
  // a terminal script is `cast`'s, whichever way it was meant to be narrated
163
232
  const mixedUp = wrongRecorder('narrate', plan.deck);
164
233
  if (mixedUp) { console.error(mixedUp); return 2; } // the code record and cast give it
234
+ // an engine re-voices a slide from its notes in seconds; --beats exists
235
+ // because reading a slide aloud again is what costs
236
+ if (!plan.mic && argv.includes('--beats')) {
237
+ console.error('decklight narrate: --beats re-records beats of your own voice; it goes with --mic');
238
+ return 2;
239
+ }
165
240
  if (plan.mic) {
166
241
  const { recordMain } = await import('./record.mjs');
167
242
  return recordMain(plan.args);
package/cli/open.mjs CHANGED
@@ -118,7 +118,7 @@ const USAGE_ALL = `usage: decklight <deck.html | git url> [--no-trust] [--port 8
118
118
  --commit-messages an agent writes EVERY commit subject instead of the generic
119
119
  "autosave" — reads each commit's diff and amends the subject
120
120
  afterwards — and K drafts one as it opens. Without it, K's
121
- "write them for me" asks only when you press it
121
+ "write it for me" asks only when you press it
122
122
  --no-commit-messages no agent-written subjects at all this session. Either
123
123
  way the deck's changes go to the agent installed on this
124
124
  machine, which may pass them to its provider
@@ -616,6 +616,9 @@ export async function openMain(args) {
616
616
  // window worth having — so the banner waits on NAMES, not on a clock.
617
617
  waiting: new Set(run.map((svc) => svc.tag)),
618
618
  };
619
+ // which child reports the deck's URL, and whether it has yet (see settle)
620
+ const urlTag = editSvc?.tag ?? null;
621
+ let urlReported = false;
619
622
  if (portRow) banner.rows.set('port', portRow);
620
623
  for (const r of movedRows) banner.rows.set(r.key, { text: r.text, mark: 'warn' });
621
624
 
@@ -634,8 +637,18 @@ export async function openMain(args) {
634
637
  else banner.held.push(line);
635
638
  }
636
639
 
637
- function flushBanner() {
640
+ function flushBanner({ force = false } = {}) {
638
641
  if (banner.done) return;
642
+ // Not before the deck server has said where it listens, the cap included:
643
+ // the url `open` planned is not one that answers yet — and with --port 0
644
+ // it never is. A slow git setup ahead of the listen (seconds on Windows
645
+ // CI) used to put http://127.0.0.1:0/ on the banner. Its exit forces it.
646
+ if (!force && urlTag && !urlReported) {
647
+ clearTimeout(banner.timer);
648
+ banner.timer = setTimeout(flushBanner, 250);
649
+ banner.timer.unref?.();
650
+ return;
651
+ }
639
652
  banner.done = true;
640
653
  clearTimeout(banner.timer);
641
654
  // Held output goes FIRST, and the banner closes. Everything in here is a
@@ -663,7 +676,12 @@ export async function openMain(args) {
663
676
  * short grace after that for the genuinely late — the review check fires
664
677
  * detached, after the deck server is already listening.
665
678
  */
666
- function settle(tag) {
679
+ function settle(tag, { exited = false } = {}) {
680
+ // The deck server owes the URL, the one line the banner exists for. A row
681
+ // it reports first (`git`, set up before it listens) does not settle it:
682
+ // on a slow machine the grace timer then printed the PLANNED url — :0 for
683
+ // --port 0 — before the real one arrived (windows CI, clone-deck test).
684
+ if (tag === urlTag && !urlReported && !exited) return;
667
685
  banner.waiting.delete(tag);
668
686
  const delay = nextFlushDelay({
669
687
  waiting: banner.waiting.size,
@@ -678,7 +696,7 @@ export async function openMain(args) {
678
696
  }
679
697
 
680
698
  function collect(tag, fact) {
681
- if (fact.url) banner.url = fact.url;
699
+ if (fact.url) { banner.url = fact.url; if (tag === urlTag) urlReported = true; }
682
700
  if (fact.keys) banner.keys = fact.keys;
683
701
  if (!fact.key || !fact.text) { if (fact.url) settle(tag); return; }
684
702
  if (banner.done) {
@@ -749,7 +767,7 @@ export async function openMain(args) {
749
767
  if (svc.name === 'edit') {
750
768
  // the deck server is the one service `open` cannot run without
751
769
  say(`${paint(svc.tag)} exited (${code}) — stopping decklight`);
752
- flushBanner();
770
+ flushBanner({ force: true });
753
771
  shutdown(code ?? 1);
754
772
  } else {
755
773
  // A bridge that stood aside because its port already has one exits 0
@@ -761,7 +779,7 @@ export async function openMain(args) {
761
779
  if (banner.done) process.stderr.write(`${bannerRow({ key: svc.tag, ...row }, { color: tty })}\n`);
762
780
  else banner.rows.set(svc.tag, row);
763
781
  }
764
- settle(svc.tag); // settle() does the delete and the "is anyone left" itself
782
+ settle(svc.tag, { exited: true }); // settle() does the delete and the "is anyone left" itself
765
783
  }
766
784
  });
767
785
  }