paperlint 19.0.1 → 19.0.3

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 (93) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CLAUDE.md +2 -2
  3. package/dist/CLAUDE.md.spec.d.ts.map +1 -1
  4. package/dist/CLAUDE.md.spec.js +7 -1
  5. package/dist/CLAUDE.md.spec.js.map +1 -1
  6. package/dist/cli.d.ts +2 -21
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +46 -98
  9. package/dist/cli.js.map +1 -1
  10. package/dist/doctor.d.ts +8 -10
  11. package/dist/doctor.d.ts.map +1 -1
  12. package/dist/doctor.js +27 -37
  13. package/dist/doctor.js.map +1 -1
  14. package/dist/folder-layout-hook.js +1 -1
  15. package/dist/hooks-notice.d.ts +9 -1
  16. package/dist/hooks-notice.d.ts.map +1 -1
  17. package/dist/hooks-notice.js +16 -18
  18. package/dist/hooks-notice.js.map +1 -1
  19. package/dist/hooks-settings.d.ts +1 -1
  20. package/dist/hooks-settings.js +1 -1
  21. package/dist/init.d.ts +1 -1
  22. package/dist/init.js +5 -5
  23. package/dist/lib/paper-config.d.ts +4 -9
  24. package/dist/lib/paper-config.d.ts.map +1 -1
  25. package/dist/lib/paper-config.js +4 -9
  26. package/dist/lib/paper-config.js.map +1 -1
  27. package/dist/papers-roots.d.ts +19 -0
  28. package/dist/papers-roots.d.ts.map +1 -0
  29. package/dist/papers-roots.js +42 -0
  30. package/dist/papers-roots.js.map +1 -0
  31. package/dist/retired-hooks.d.ts +6 -0
  32. package/dist/retired-hooks.d.ts.map +1 -0
  33. package/dist/retired-hooks.js +34 -0
  34. package/dist/retired-hooks.js.map +1 -0
  35. package/dist/skill-chunks/chunk-C2G5EK7S.js +579 -0
  36. package/dist/skill-chunks/{chunk-UL4INX2P.js → chunk-L3NJUJUP.js} +446 -446
  37. package/dist/skill-chunks/{chunk-EOVEVX67.js → chunk-X4VKG4KT.js} +1 -1
  38. package/dist/types.d.ts +1 -1
  39. package/docs/install.md +12 -14
  40. package/docs/layout.md +2 -5
  41. package/docs/rules/paper/allowed-files-only.md +1 -2
  42. package/docs/testing.md +1 -1
  43. package/eslint.config.mjs +1 -1
  44. package/lib/paper-config.harness.mjs +4 -8
  45. package/lib/paper-config.ts +4 -9
  46. package/package.json +2 -3
  47. package/plugin/hooks/hooks.json +0 -22
  48. package/scripts/coverage-config.test.ts +0 -1
  49. package/scripts/eslint-file-length.mjs +0 -1
  50. package/skills/argument-arc/scripts/headings.js +2 -2
  51. package/skills/build-label-page/scripts/label-page.js +125 -125
  52. package/skills/cold-read-diff/scripts/cold-read.js +11 -11
  53. package/skills/paper-pipeline/scripts/extract-ref-facts.js +3 -3
  54. package/skills/paper-status/SKILL.md +1 -2
  55. package/skills/paper-status/SKILL.md.spec.ts +0 -1
  56. package/skills/pc-panel-review/scripts/prior-reviews.js +1 -1
  57. package/skills/verify-citations/scripts/bib-authors.js +3 -3
  58. package/skills/verify-citations/scripts/verify-cites.js +3 -3
  59. package/src/CLAUDE.md +16 -1
  60. package/src/CLAUDE.md.spec.ts +12 -1
  61. package/src/cli.harness.mjs +16 -80
  62. package/src/cli.test.ts +6 -36
  63. package/src/cli.ts +49 -145
  64. package/src/doctor.harness.mjs +17 -59
  65. package/src/doctor.test.ts +1 -1
  66. package/src/doctor.ts +26 -41
  67. package/src/domain/paper-folder.test.ts +1 -1
  68. package/src/folder-layout-hook.ts +1 -1
  69. package/src/hooks-notice.test.ts +21 -74
  70. package/src/hooks-notice.ts +37 -18
  71. package/src/hooks-settings.harness.ts +27 -29
  72. package/src/hooks-settings.ts +1 -1
  73. package/src/in-process-hooks.test.ts +18 -0
  74. package/src/init.ts +5 -5
  75. package/src/lint-edited-site-example.test.ts +0 -3
  76. package/src/papers-roots.test.ts +56 -0
  77. package/src/papers-roots.ts +56 -0
  78. package/src/retired-hooks.test.ts +155 -0
  79. package/src/retired-hooks.ts +41 -0
  80. package/src/types.ts +1 -1
  81. package/dist/skill-chunks/chunk-GRSXIWYF.js +0 -352
  82. package/hooks/CLAUDE.md +0 -34
  83. package/hooks/CLAUDE.md.spec.ts +0 -30
  84. package/hooks/hooks.harness.ts +0 -704
  85. package/hooks/paper-edit-guard.hook.d.mts +0 -12
  86. package/hooks/paper-edit-guard.hook.mjs +0 -443
  87. package/hooks/paper-edit-guard.test.ts +0 -66
  88. package/hooks/paper-skills-nudge.hook.d.mts +0 -22
  89. package/hooks/paper-skills-nudge.hook.mjs +0 -199
  90. package/hooks/paper-skills-nudge.test.ts +0 -122
  91. package/hooks/paper-status-gates.hook.mjs +0 -158
  92. package/hooks/paper-status-gates.sh +0 -93
  93. package/hooks/paper-status-gates.test.ts +0 -101
@@ -6,23 +6,23 @@ const require = __plCreateRequire(import.meta.url);
6
6
  const __filename = __plFileURLToPath(import.meta.url);
7
7
  const __dirname = __plDirname(__filename);
8
8
  import {
9
- e,
10
- e2,
11
- n,
12
- n2,
13
- t11 as t7,
14
- t12 as t8,
15
- t15 as t9,
16
- t16 as t10,
17
- t17 as t11,
18
- t18 as t12,
19
- t3 as t,
20
- t5 as t2,
21
- t6 as t3,
22
- t7 as t4,
23
- t8 as t5,
24
- t9 as t6
25
- } from "../../../dist/skill-chunks/chunk-GRSXIWYF.js";
9
+ entries,
10
+ flatMap,
11
+ forEachObj,
12
+ fromKeys,
13
+ indexBy,
14
+ isDefined,
15
+ isIncludedIn,
16
+ mapKeys,
17
+ mapValues,
18
+ omit,
19
+ pick,
20
+ pickBy,
21
+ pipe,
22
+ pullObject,
23
+ sortBy,
24
+ unique
25
+ } from "../../../dist/skill-chunks/chunk-C2G5EK7S.js";
26
26
  import {
27
27
  external_exports
28
28
  } from "../../../dist/skill-chunks/chunk-4MHEJ6FR.js";
@@ -68,7 +68,7 @@ var Builtins = external_exports.object({
68
68
  });
69
69
  function pluginsOf(id) {
70
70
  const [first = "", second = "", ...rest] = id.split("/");
71
- const after = (n3) => id.split("/").slice(n3).join("/");
71
+ const after = (n) => id.split("/").slice(n).join("/");
72
72
  return id.startsWith("@") ? [
73
73
  ...rest.length ? [[`${first}/eslint-plugin-${second}`, after(2)]] : [],
74
74
  [`${first}/eslint-plugin`, after(1)]
@@ -245,14 +245,14 @@ var PRESETS = {
245
245
  schema: LINTER_CARD
246
246
  }
247
247
  };
248
- var issuesOf = (where, e3) => e3.issues.map(
248
+ var issuesOf = (where, e) => e.issues.map(
249
249
  (issue) => `${where}${issue.path.map(
250
250
  (p) => typeof p === "number" ? `[${String(p)}]` : `.${String(p)}`
251
251
  ).join("")}: ${issue.message}`
252
252
  ).join("; ");
253
253
  var mapCards = (preset, practice, items) => [
254
- ...practice.map((c, n3) => [`practice[${String(n3)}]`, c]),
255
- ...items.map((c, n3) => [`items[${String(n3)}]`, c])
254
+ ...practice.map((c, n) => [`practice[${String(n)}]`, c]),
255
+ ...items.map((c, n) => [`items[${String(n)}]`, c])
256
256
  ].map(([at2, c]) => {
257
257
  const r = preset.schema.safeParse(c);
258
258
  return r.success ? { ok: true, value: preset.card(r.data) } : { ok: false, message: issuesOf(at2, r.error) };
@@ -334,8 +334,8 @@ var withPreset = (raw) => {
334
334
  var readJson = (path) => {
335
335
  try {
336
336
  return JSON_VALUE.parse(JSON.parse(readFileSync(path, "utf8")));
337
- } catch (e3) {
338
- return fail(`cannot read ${path} as JSON: ${String(e3)}`);
337
+ } catch (e) {
338
+ return fail(`cannot read ${path} as JSON: ${String(e)}`);
339
339
  }
340
340
  };
341
341
  var PAGE_FIELDS = ["group", "title", "body", "code", "context", "file"];
@@ -694,16 +694,16 @@ function checkString(value, node, where) {
694
694
  fail(`${where}: ${repr(value)} must be ${node.why ?? ID_RULE}`);
695
695
  }
696
696
  }
697
- var checkCount = (n3, min, where) => {
698
- if (n3 < min)
699
- fail(`${where}: needs ${String(min)} or more entries, has ${String(n3)}`);
697
+ var checkCount = (n, min, where) => {
698
+ if (n < min)
699
+ fail(`${where}: needs ${String(min)} or more entries, has ${String(n)}`);
700
700
  };
701
701
  function checkArray(value, node, path, where) {
702
702
  if (!isList(value))
703
703
  return fail(`${where}: must be a list, got ${repr(value)}`);
704
704
  checkCount(value.length, node.min, where);
705
- value.forEach((entry, n3) => {
706
- checkValue(entry, node.items, `${path}[${String(n3)}]`);
705
+ value.forEach((entry, n) => {
706
+ checkValue(entry, node.items, `${path}[${String(n)}]`);
707
707
  });
708
708
  }
709
709
  function checkMap(value, node, path, where) {
@@ -799,9 +799,9 @@ function checkGroups(cfg) {
799
799
  `groups.${String(ids[twice.at])}: ${repr(labels[twice.at])} reads the same as groups.${String(ids[twice.earlier])} \u2014 each group needs its own label`
800
800
  );
801
801
  }
802
- (cfg.labeller_knows ?? []).forEach((gid, n3) => {
802
+ (cfg.labeller_knows ?? []).forEach((gid, n) => {
803
803
  if (!has(cfg.groups, gid))
804
- fail(`labeller_knows[${String(n3)}]: ${repr(gid)} is not in \`groups\``);
804
+ fail(`labeller_knows[${String(n)}]: ${repr(gid)} is not in \`groups\``);
805
805
  });
806
806
  }
807
807
  function checkQuestion(q, qn, earlierIds) {
@@ -827,8 +827,8 @@ function checkPractice(cfg) {
827
827
  if ((cfg.practice_round ?? 1) < 1) {
828
828
  fail(`practice_round: ${repr(cfg.practice_round)} \u2014 must be 1 or more`);
829
829
  }
830
- cfg.practice.forEach((item, n3) => {
831
- const where = `practice[${String(n3)}].expected`;
830
+ cfg.practice.forEach((item, n) => {
831
+ const where = `practice[${String(n)}].expected`;
832
832
  for (const [q, v] of Object.entries(item.expected)) {
833
833
  const values = offered[q];
834
834
  if (values === void 0)
@@ -853,15 +853,15 @@ function checkAnswerers(cfg) {
853
853
  fail(`min_seconds: ${repr(cfg.min_seconds)} \u2014 must be 1 or more`);
854
854
  const all = cfg.answerers;
855
855
  if (all !== void 0) checkDistinct(all, "answerers");
856
- cfg.items.forEach((item, n3) => {
857
- const where = `items[${String(n3)}].answerers`;
856
+ cfg.items.forEach((item, n) => {
857
+ const where = `items[${String(n)}].answerers`;
858
858
  const own = item.answerers;
859
859
  if (own === void 0) return;
860
860
  if (all === void 0)
861
861
  return fail(
862
862
  `${where}: the page has no \`answerers\` \u2014 add the page's list, or take this out`
863
863
  );
864
- const k = own.findIndex((who) => !e2(who, all));
864
+ const k = own.findIndex((who) => !isIncludedIn(who, all));
865
865
  if (k !== -1)
866
866
  fail(
867
867
  `${where}[${String(k)}]: ${repr(own[k])} is not in \`answerers\` (${all.join(", ")})`
@@ -886,19 +886,19 @@ function checkConfig(cfg) {
886
886
  });
887
887
  checkPractice(cfg);
888
888
  }
889
- var practiceOf = (cfg) => cfg.practice.map((item, n3) => ({ id: `P${String(n3 + 1)}`, ...item }));
890
- var linesOf = (cfg) => cfg.items.reduce((byLine, item, n3) => {
889
+ var practiceOf = (cfg) => cfg.practice.map((item, n) => ({ id: `P${String(n + 1)}`, ...item }));
890
+ var linesOf = (cfg) => cfg.items.reduce((byLine, item, n) => {
891
891
  if (item.unit === void 0) return byLine;
892
- const part = { item, unit: item.unit, n: n3 };
892
+ const part = { item, unit: item.unit, n };
893
893
  const seen = byLine.get(item.unit.id);
894
894
  return byLine.set(
895
895
  item.unit.id,
896
896
  seen ? [seen[0], ...seen.slice(1), part] : [part]
897
897
  );
898
898
  }, /* @__PURE__ */ new Map());
899
- function checkPart({ item, unit, n: n3 }, parts) {
899
+ function checkPart({ item, unit, n }, parts) {
900
900
  const [first] = parts;
901
- const at2 = `items[${String(n3)}]`;
901
+ const at2 = `items[${String(n)}]`;
902
902
  if (unit.text !== first.unit.text)
903
903
  fail(
904
904
  `${at2}.unit.text: ${repr(unit.text)}, but items[${String(first.n)}] of line ${repr(unit.id)} says ${repr(first.unit.text)}`
@@ -907,7 +907,7 @@ function checkPart({ item, unit, n: n3 }, parts) {
907
907
  fail(
908
908
  `${at2}.unit.of: ${String(unit.of)}, but items[${String(first.n)}].unit.of says ${String(first.unit.of)} for the same line`
909
909
  );
910
- const earlier = parts.find((p) => p.n < n3 && p.unit.part === unit.part);
910
+ const earlier = parts.find((p) => p.n < n && p.unit.part === unit.part);
911
911
  if (earlier !== void 0)
912
912
  fail(
913
913
  `${at2}.unit.part: ${String(unit.part)} repeats items[${String(earlier.n)}].unit.part`
@@ -963,7 +963,7 @@ function checkBlocks(cfg) {
963
963
  });
964
964
  }
965
965
  var SOURCE_COLOURS = 5;
966
- var tagsOf = (at2, card) => t(
966
+ var tagsOf = (at2, card) => pipe(
967
967
  [
968
968
  { field: "quote.from", id: card.quote?.from, over: "text" },
969
969
  {
@@ -983,7 +983,7 @@ var tagsOf = (at2, card) => t(
983
983
  over: card.excerpt?.annotation
984
984
  }
985
985
  ],
986
- t3(
986
+ flatMap(
987
987
  ({ field, id, over }) => id === void 0 ? [] : [{ at: `${at2}.${field}`, id, over }]
988
988
  )
989
989
  );
@@ -994,28 +994,28 @@ function checkSources(cfg) {
994
994
  fail(
995
995
  `sources: ${String(ids.length)} ids, and the page has ${String(SOURCE_COLOURS)} colours for tags \u2014 merge ids, or drop one`
996
996
  );
997
- tags.forEach((t13) => {
997
+ tags.forEach((t) => {
998
998
  if (cfg.sources === void 0)
999
999
  fail(
1000
- `${t13.at}: names the source ${repr(t13.id)}, and the page has no \`sources\` \u2014 add them, or take the tag out`
1000
+ `${t.at}: names the source ${repr(t.id)}, and the page has no \`sources\` \u2014 add them, or take the tag out`
1001
1001
  );
1002
- else if (!has(cfg.sources, t13.id))
1003
- fail(`${t13.at}: ${repr(t13.id)} is not in \`sources\` (${ids.join(", ")})`);
1004
- if (t13.over === void 0)
1002
+ else if (!has(cfg.sources, t.id))
1003
+ fail(`${t.at}: ${repr(t.id)} is not in \`sources\` (${ids.join(", ")})`);
1004
+ if (t.over === void 0)
1005
1005
  fail(
1006
- `${t13.at}: tags a text the card does not have \u2014 add it, or take the tag out`
1006
+ `${t.at}: tags a text the card does not have \u2014 add it, or take the tag out`
1007
1007
  );
1008
1008
  });
1009
- const dead = ids.find((id) => !tags.some((t13) => t13.id === id));
1009
+ const dead = ids.find((id) => !tags.some((t) => t.id === id));
1010
1010
  if (dead !== void 0)
1011
1011
  fail(
1012
1012
  `sources.${dead}: no item or practice item names it \u2014 a tag nothing carries is a dead entry`
1013
1013
  );
1014
1014
  }
1015
1015
  var termTexts = (card) => [card.quote?.text, card.quote?.source, card.excerpt?.annotation].filter(
1016
- e
1016
+ isDefined
1017
1017
  );
1018
- var findsTerm = (card, term) => termTexts(card).some((t13) => t13.split("`").some((part) => part.includes(term)));
1018
+ var findsTerm = (card, term) => termTexts(card).some((t) => t.split("`").some((part) => part.includes(term)));
1019
1019
  function checkCardText(cfg) {
1020
1020
  const options = new Map(
1021
1021
  cfg.questions.map((q) => [q.id, q.options.map((o) => o.value)])
@@ -1030,7 +1030,7 @@ function checkCardText(cfg) {
1030
1030
  });
1031
1031
  }
1032
1032
  function checkTermsDoNotOverlap(at2, card) {
1033
- const texts = (card.terms ?? []).map((t13) => t13.term);
1033
+ const texts = (card.terms ?? []).map((t) => t.term);
1034
1034
  const named = (k) => `${at2}.terms[${String(k)}]`;
1035
1035
  texts.forEach((inner, k) => {
1036
1036
  const j = texts.findIndex(
@@ -1044,14 +1044,14 @@ function checkTermsDoNotOverlap(at2, card) {
1044
1044
  }
1045
1045
  function checkTerms(at2, card) {
1046
1046
  checkTermsDoNotOverlap(at2, card);
1047
- (card.terms ?? []).forEach((t13, k) => {
1047
+ (card.terms ?? []).forEach((t, k) => {
1048
1048
  const where = `${at2}.terms[${String(k)}]`;
1049
- if (!findsTerm(card, t13.term))
1049
+ if (!findsTerm(card, t.term))
1050
1050
  fail(
1051
- `${where}.term: ${repr(t13.term)} is not in the card's annotation, quote or quote source \u2014 a note opens from words the card shows`
1051
+ `${where}.term: ${repr(t.term)} is not in the card's annotation, quote or quote source \u2014 a note opens from words the card shows`
1052
1052
  );
1053
- const bare = t13.note.findIndex(
1054
- (e3) => e3.quote === void 0 && e3.code === void 0
1053
+ const bare = t.note.findIndex(
1054
+ (e) => e.quote === void 0 && e.code === void 0
1055
1055
  );
1056
1056
  if (bare !== -1)
1057
1057
  fail(
@@ -1074,26 +1074,26 @@ function checkAnswerNotes(at2, card, options) {
1074
1074
  });
1075
1075
  }
1076
1076
  var cardsOf = (cfg) => [
1077
- ...cfg.items.map((i, n3) => [`items[${String(n3)}]`, i]),
1078
- ...cfg.practice.map((p, n3) => [`practice[${String(n3)}]`, p])
1077
+ ...cfg.items.map((i, n) => [`items[${String(n)}]`, i]),
1078
+ ...cfg.practice.map((p, n) => [`practice[${String(n)}]`, p])
1079
1079
  ];
1080
1080
  function checkItemFields(cfg) {
1081
1081
  const sids = [];
1082
- cfg.items.forEach((item, n3) => {
1082
+ cfg.items.forEach((item, n) => {
1083
1083
  const extra = Object.keys(item).filter((f) => !ALLOWED_FIELDS.includes(f)).sort();
1084
1084
  if (extra.length) {
1085
1085
  fail(
1086
- `item #${String(n3)} (${item.source_id}) carries ${extra.join(", ")}, which is not in the allow-list ${repr([...ALLOWED_FIELDS].sort())}. A blind page shows the labeller the item and nothing about the answer or the source. Remove the field from items.json; add it to PAGE_FIELDS only if it is safe for the labeller to see.`
1086
+ `item #${String(n)} (${item.source_id}) carries ${extra.join(", ")}, which is not in the allow-list ${repr([...ALLOWED_FIELDS].sort())}. A blind page shows the labeller the item and nothing about the answer or the source. Remove the field from items.json; add it to PAGE_FIELDS only if it is safe for the labeller to see.`
1087
1087
  );
1088
1088
  }
1089
1089
  if (sids.includes(item.source_id))
1090
1090
  fail(
1091
- `items[${String(n3)}].source_id: ${repr(item.source_id)} is repeated`
1091
+ `items[${String(n)}].source_id: ${repr(item.source_id)} is repeated`
1092
1092
  );
1093
1093
  sids.push(item.source_id);
1094
1094
  if (!has(cfg.groups, item.group))
1095
1095
  fail(
1096
- `items[${String(n3)}].group: ${repr(item.group)} is not in \`groups\``
1096
+ `items[${String(n)}].group: ${repr(item.group)} is not in \`groups\``
1097
1097
  );
1098
1098
  });
1099
1099
  }
@@ -1101,7 +1101,7 @@ var stringsIn = (v) => typeof v === "string" ? [v] : Array.isArray(v) ? v.flatMa
1101
1101
  var visibleTexts = (item) => Object.entries({
1102
1102
  ...shownFields(item),
1103
1103
  [RULES_FIELD]: item.rules ?? []
1104
- }).flatMap(([f, v]) => stringsIn(v).map((t13) => [f, t13]));
1104
+ }).flatMap(([f, v]) => stringsIn(v).map((t) => [f, t]));
1105
1105
  var escapeRegExp = (s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&");
1106
1106
  function checkNoSourceShown(cfg) {
1107
1107
  const long = cfg.items.map((i) => i.source_id).filter((sid) => sid.length >= 4);
@@ -1128,15 +1128,15 @@ function checkPresence(where, shown, given) {
1128
1128
  if (shown === void 0 && given !== void 0)
1129
1129
  fail(`${where}: is never shown \u2014 the page has no text it translates`);
1130
1130
  }
1131
- function checkSituationWords(cfg, at2, t13) {
1131
+ function checkSituationWords(cfg, at2, t) {
1132
1132
  const cards = cardsOf(cfg).filter(([, c]) => c.situation !== void 0);
1133
1133
  const first = cards[0];
1134
1134
  checkPresence(
1135
1135
  `${at2}.situation_question`,
1136
1136
  first && `${first[0]}.situation asks the first question in the card's own words`,
1137
- t13.situation_question
1137
+ t.situation_question
1138
1138
  );
1139
- const q = t13.situation_question ?? "";
1139
+ const q = t.situation_question ?? "";
1140
1140
  const bare = cards.find(([, c]) => lineOf(c) === void 0);
1141
1141
  if (bare !== void 0 && [NUMBER_TOKEN, LINE_TOKEN].some((token) => q.includes(token)))
1142
1142
  fail(
@@ -1153,15 +1153,15 @@ var optionIn = (o, words, where) => {
1153
1153
  w.ask_why
1154
1154
  );
1155
1155
  return {
1156
- ...n(o, ["ask_why"]),
1156
+ ...omit(o, ["ask_why"]),
1157
1157
  label: w.label,
1158
1158
  example: w.example,
1159
- ...t10({ ask_why: w.ask_why }, e)
1159
+ ...pickBy({ ask_why: w.ask_why }, isDefined)
1160
1160
  };
1161
1161
  };
1162
- function questionIn(q, t13, at2) {
1162
+ function questionIn(q, t, at2) {
1163
1163
  const where = `${at2}.questions.${q.id}`;
1164
- const words = t13.questions[q.id] ?? fail(
1164
+ const words = t.questions[q.id] ?? fail(
1165
1165
  `${where}: is required and missing \u2014 every question of the page is translated`
1166
1166
  );
1167
1167
  const values = q.options.map((o) => o.value);
@@ -1177,25 +1177,25 @@ function questionIn(q, t13, at2) {
1177
1177
  return {
1178
1178
  id: q.id,
1179
1179
  text: words.text,
1180
- ...t10({ short: words.short }, e),
1180
+ ...pickBy({ short: words.short }, isDefined),
1181
1181
  options
1182
1182
  };
1183
1183
  }
1184
- function checkTranslatedSources(cfg, at2, t13) {
1184
+ function checkTranslatedSources(cfg, at2, t) {
1185
1185
  const known = Object.keys(cfg.sources ?? {});
1186
- const stray = Object.keys(t13.sources ?? {}).find((id) => !known.includes(id));
1186
+ const stray = Object.keys(t.sources ?? {}).find((id) => !known.includes(id));
1187
1187
  if (stray !== void 0)
1188
1188
  fail(
1189
1189
  `${at2}.sources.${stray}: not one of the page's \`sources\` (${known.join(", ") || "none"})`
1190
1190
  );
1191
1191
  }
1192
- var optionalWords = (t13) => t10(
1193
- { situation_question: t13.situation_question, sources: t13.sources },
1194
- e
1192
+ var optionalWords = (t) => pickBy(
1193
+ { situation_question: t.situation_question, sources: t.sources },
1194
+ isDefined
1195
1195
  );
1196
1196
  function translationsOf(cfg) {
1197
1197
  const base = cfg.lang ?? BASE_LANG;
1198
- return t8(cfg.translations ?? {}, (t13, lang) => {
1198
+ return mapValues(cfg.translations ?? {}, (t, lang) => {
1199
1199
  const at2 = `translations.${lang}`;
1200
1200
  if (lang === base)
1201
1201
  fail(
@@ -1204,26 +1204,26 @@ function translationsOf(cfg) {
1204
1204
  checkPresence(
1205
1205
  `${at2}.intro`,
1206
1206
  cfg.intro && "the page has an `intro`",
1207
- t13.intro
1207
+ t.intro
1208
1208
  );
1209
- checkSituationWords(cfg, at2, t13);
1210
- checkTranslatedSources(cfg, at2, t13);
1209
+ checkSituationWords(cfg, at2, t);
1210
+ checkTranslatedSources(cfg, at2, t);
1211
1211
  const ids = cfg.questions.map((q) => q.id);
1212
- const stray = Object.keys(t13.questions).find((id) => !ids.includes(id));
1212
+ const stray = Object.keys(t.questions).find((id) => !ids.includes(id));
1213
1213
  if (stray !== void 0)
1214
1214
  fail(
1215
1215
  `${at2}.questions.${stray}: not a question of this page (${ids.join(", ")})`
1216
1216
  );
1217
1217
  return {
1218
- title: t13.title ?? cfg.title,
1219
- intro: t13.intro ?? "",
1220
- labels: { ...DEFAULT_LABELS, ...cfg.labels, ...t13.labels },
1221
- ...optionalWords(t13),
1222
- questions: cfg.questions.map((q) => questionIn(q, t13, at2))
1218
+ title: t.title ?? cfg.title,
1219
+ intro: t.intro ?? "",
1220
+ labels: { ...DEFAULT_LABELS, ...cfg.labels, ...t.labels },
1221
+ ...optionalWords(t),
1222
+ questions: cfg.questions.map((q) => questionIn(q, t, at2))
1223
1223
  };
1224
1224
  });
1225
1225
  }
1226
- var languagesOf = (cfg, translated) => cfg.translations === void 0 ? t10({ lang: cfg.lang }, e) : { lang: cfg.lang ?? BASE_LANG, translations: translated };
1226
+ var languagesOf = (cfg, translated) => cfg.translations === void 0 ? pickBy({ lang: cfg.lang }, isDefined) : { lang: cfg.lang ?? BASE_LANG, translations: translated };
1227
1227
  function assertOwnKey(_value) {
1228
1228
  }
1229
1229
  var readOldKey = (keyPath, seed) => {
@@ -1239,9 +1239,9 @@ var readOldKey = (keyPath, seed) => {
1239
1239
  };
1240
1240
  function assignIds(items, seed, keyPath) {
1241
1241
  const old = readOldKey(keyPath, seed);
1242
- const entries = old?.ids ?? {};
1242
+ const entries2 = old?.ids ?? {};
1243
1243
  const known = new Map(
1244
- Object.entries(entries).map(([nid, v]) => [v.source_id, nid])
1244
+ Object.entries(entries2).map(([nid, v]) => [v.source_id, nid])
1245
1245
  );
1246
1246
  const rank = (s) => createHash("sha256").update(`${String(seed)}:${s}`).digest("hex");
1247
1247
  const fresh = items.map((i) => i.source_id).filter((sid) => !known.has(sid)).sort((a, b) => byText(rank(a), rank(b)));
@@ -1252,13 +1252,13 @@ function assignIds(items, seed, keyPath) {
1252
1252
  `G${String(known.size + k + 1).padStart(3, "0")}`
1253
1253
  ])
1254
1254
  ]);
1255
- return { ids, entries };
1255
+ return { ids, entries: entries2 };
1256
1256
  }
1257
1257
  var situationShown = (item) => item.situation === void 0 ? {} : {
1258
1258
  situation: {
1259
- ...t10(
1259
+ ...pickBy(
1260
1260
  { summary: item.situation.summary, from: item.situation.from },
1261
- e
1261
+ isDefined
1262
1262
  ),
1263
1263
  question: item.situation.question,
1264
1264
  ...usesLine(item) ? { line: lineOf(item) } : {}
@@ -1316,10 +1316,10 @@ function itemsOnPage(cfg, keyPath) {
1316
1316
  (i) => knows === void 0 || knows.includes(i.group)
1317
1317
  );
1318
1318
  if (!items.length) fail("no item is left after `labeller_knows`");
1319
- const { ids, entries } = assignIds(items, cfg.seed, keyPath);
1319
+ const { ids, entries: entries2 } = assignIds(items, cfg.seed, keyPath);
1320
1320
  const idOf = (i) => String(ids.get(i.source_id));
1321
1321
  const sorted = [...items].sort((a, b) => byText(idOf(a), idOf(b)));
1322
- return { items: sorted, ids, entries, idOf };
1322
+ return { items: sorted, ids, entries: entries2, idOf };
1323
1323
  }
1324
1324
  var practiceRound = (cfg) => cfg.practice_round ?? 1;
1325
1325
  var practiceShown = (cfg, described) => practiceOf(cfg).map((p) => ({
@@ -1347,13 +1347,13 @@ var sourcesShown = (cfg) => cfg.sources === void 0 ? {} : {
1347
1347
  label
1348
1348
  }))
1349
1349
  };
1350
- var optionalKeys = (cfg) => t10(
1350
+ var optionalKeys = (cfg) => pickBy(
1351
1351
  {
1352
1352
  answerers: cfg.answerers,
1353
1353
  min_seconds: cfg.min_seconds,
1354
1354
  practice_gate: cfg.practice_gate
1355
1355
  },
1356
- e
1356
+ isDefined
1357
1357
  );
1358
1358
  function payloadOf(cfg, page, described, translated) {
1359
1359
  const used = Object.keys(cfg.groups).filter(
@@ -1382,7 +1382,7 @@ var itemShown = (i, id, described) => ({
1382
1382
  id,
1383
1383
  ...shownFields(i),
1384
1384
  ...rulesShown(i, described),
1385
- ...t10({ answerers: i.answerers }, e)
1385
+ ...pickBy({ answerers: i.answerers }, isDefined)
1386
1386
  });
1387
1387
  function idsOf(cfg, page) {
1388
1388
  const shown = new Set(page.items.map(page.idOf));
@@ -1393,16 +1393,16 @@ function idsOf(cfg, page) {
1393
1393
  ]),
1394
1394
  ...cfg.items.map((i) => [i.source_id, i.group])
1395
1395
  ]);
1396
- const bySource = t6(cfg.items, (i) => i.source_id);
1396
+ const bySource = indexBy(cfg.items, (i) => i.source_id);
1397
1397
  const byId = [...page.ids].sort(([, a], [, b]) => byText(a, b));
1398
- return t11(
1398
+ return pullObject(
1399
1399
  byId,
1400
1400
  ([, nid]) => nid,
1401
1401
  ([sid, nid]) => ({
1402
1402
  source_id: sid,
1403
1403
  group: String(groupOf.get(sid)),
1404
1404
  on_page: shown.has(nid),
1405
- ...t10({ answerers: bySource[sid]?.answerers }, e)
1405
+ ...pickBy({ answerers: bySource[sid]?.answerers }, isDefined)
1406
1406
  })
1407
1407
  );
1408
1408
  }
@@ -1504,25 +1504,25 @@ var practiceDocs = (key) => {
1504
1504
  };
1505
1505
  var shownTo = (all, meta) => meta.answerers ?? all;
1506
1506
  function knownNames(key, whose) {
1507
- const entries = Object.entries(key.ids).filter(
1507
+ const entries2 = Object.entries(key.ids).filter(
1508
1508
  ([, m]) => whose.who === void 0 || shownTo(whose.all, m).includes(whose.who)
1509
1509
  );
1510
- const shown = entries.filter(([, m]) => m.on_page);
1510
+ const shown = entries2.filter(([, m]) => m.on_page);
1511
1511
  const practice = practiceDocs(key);
1512
1512
  return {
1513
1513
  answers: {
1514
- known: entries.map(([nid]) => [nid, key.questions]),
1514
+ known: entries2.map(([nid]) => [nid, key.questions]),
1515
1515
  onPage: shown.map(([nid]) => nid),
1516
1516
  fields: answerDocFields(key)
1517
1517
  },
1518
1518
  groups: {
1519
- known: entries.map(([, m]) => [m.group, key.questions]),
1519
+ known: entries2.map(([, m]) => [m.group, key.questions]),
1520
1520
  onPage: shown.map(([, m]) => m.group),
1521
1521
  fields: GROUP_DOC_FIELDS
1522
1522
  },
1523
1523
  practice: {
1524
1524
  known: practice,
1525
- onPage: practice.map(([n3]) => n3),
1525
+ onPage: practice.map(([n]) => n),
1526
1526
  fields: answerDocFields(key)
1527
1527
  }
1528
1528
  };
@@ -1560,11 +1560,11 @@ function answererOf(where, docId, key) {
1560
1560
  return { who, all, name: docId.slice(at2 + 1) };
1561
1561
  }
1562
1562
  function checkDocName(where, { who, name }, kind, names) {
1563
- const hit = names.known.find(([n3]) => n3 === name);
1563
+ const hit = names.known.find(([n]) => n === name);
1564
1564
  if (hit === void 0) {
1565
1565
  return fail(
1566
- `${where}: the key does not know this ${NOUN[kind]}${who === void 0 ? "" : ` for ${who}`} (${n2(
1567
- names.known.map(([n3]) => n3)
1566
+ `${where}: the key does not know this ${NOUN[kind]}${who === void 0 ? "" : ` for ${who}`} (${unique(
1567
+ names.known.map(([n]) => n)
1568
1568
  ).sort().join(", ")})`
1569
1569
  );
1570
1570
  }
@@ -1665,7 +1665,7 @@ var listed = (lists, q, v) => valuesOf(lists, q).includes(v);
1665
1665
  var textOf = (v) => typeof v === "string" ? v : null;
1666
1666
  var textsOf = (o) => Object.fromEntries(
1667
1667
  Object.entries(isObject(o) ? o : {}).filter(
1668
- (e3) => typeof e3[1] === "string"
1668
+ (e) => typeof e[1] === "string"
1669
1669
  )
1670
1670
  );
1671
1671
  function answersOf(doc, ctx) {
@@ -1700,7 +1700,7 @@ function answerOf(doc, ctx) {
1700
1700
  source: textOf(doc["source"]),
1701
1701
  saved_at: doc["savedAt"] ?? null,
1702
1702
  // Only a page built with `min_seconds` stores how long the item was on screen.
1703
- ...t9({ seconds: doc["seconds"] ?? null }, secondsOf(ctx.key))
1703
+ ...pick({ seconds: doc["seconds"] ?? null }, secondsOf(ctx.key))
1704
1704
  };
1705
1705
  }
1706
1706
  var secondsOf = (key) => key.min_seconds === void 0 ? [] : ["seconds"];
@@ -1772,7 +1772,7 @@ var practiceFile = (study, round, day, who) => `${study}-practice-r${String(roun
1772
1772
  function exportPractice(dump, key, target, day) {
1773
1773
  const p = key.practice;
1774
1774
  if (p === void 0) return;
1775
- const rounds = t12(t2(roundsIn(p)), ([r]) => Number(r));
1775
+ const rounds = sortBy(entries(roundsIn(p)), ([r]) => Number(r));
1776
1776
  (key.answerers ?? [void 0]).forEach((who) => {
1777
1777
  rounds.forEach(([round, expected]) => {
1778
1778
  exportRound(
@@ -1801,7 +1801,7 @@ function exportRound(study, round, items, at2) {
1801
1801
  writeJson(path, {
1802
1802
  study,
1803
1803
  round,
1804
- ...t10({ answerer: at2.who }, e),
1804
+ ...pickBy({ answerer: at2.who }, isDefined),
1805
1805
  exported: at2.day,
1806
1806
  matched,
1807
1807
  total: items.length,
@@ -1821,7 +1821,7 @@ var tally = (items, groups) => ({
1821
1821
  total_items: items.length
1822
1822
  });
1823
1823
  var groupsFor = (onPage, dump, ctx, prefix = "") => ctx.allowed.familiarity.length ? groupsOf(
1824
- n2(onPage.map(([, m]) => m.group)),
1824
+ unique(onPage.map(([, m]) => m.group)),
1825
1825
  dump["groups"],
1826
1826
  ctx.allowed,
1827
1827
  prefix
@@ -1847,7 +1847,7 @@ function answererLabelsOf(dump, ctx, day, all) {
1847
1847
  source_id: meta.source_id,
1848
1848
  group: meta.group,
1849
1849
  answerers: shownTo(all, meta),
1850
- by_answerer: t5(shownTo(all, meta), (who) => docFor(who, nid))
1850
+ by_answerer: fromKeys(shownTo(all, meta), (who) => docFor(who, nid))
1851
1851
  }));
1852
1852
  return {
1853
1853
  study: ctx.key.study,
@@ -1855,7 +1855,7 @@ function answererLabelsOf(dump, ctx, day, all) {
1855
1855
  questions: ctx.key.questions,
1856
1856
  answerers: all,
1857
1857
  items,
1858
- by_answerer: t5(
1858
+ by_answerer: fromKeys(
1859
1859
  all,
1860
1860
  (who) => tallyOf({ who, all }, onPage, dump, ctx)
1861
1861
  )
@@ -1871,7 +1871,7 @@ function tallyOf({ who, all }, onPage, dump, ctx) {
1871
1871
  );
1872
1872
  }
1873
1873
  function reportAnswerers(out, allowed) {
1874
- t4(out.by_answerer, (t13, who) => {
1874
+ forEachObj(out.by_answerer, (t, who) => {
1875
1875
  reportLabels(
1876
1876
  out.items.flatMap((i) => {
1877
1877
  const a = i.by_answerer[who];
@@ -1880,12 +1880,12 @@ function reportAnswerers(out, allowed) {
1880
1880
  allowed
1881
1881
  );
1882
1882
  reportGroups(
1883
- t7(t13.groups, (g) => `${who}${SEP}${g}`),
1883
+ mapKeys(t.groups, (g) => `${who}${SEP}${g}`),
1884
1884
  allowed
1885
1885
  );
1886
1886
  });
1887
1887
  }
1888
- var completeLine = (t13) => `${String(t13.complete_items)} of ${String(t13.total_items)} items complete`;
1888
+ var completeLine = (t) => `${String(t.complete_items)} of ${String(t.total_items)} items complete`;
1889
1889
  function exportLabels(dumpPath, keyPath, outDir, day) {
1890
1890
  const dump = readJson(dumpPath);
1891
1891
  const key = readJson(keyPath);
@@ -1906,7 +1906,7 @@ function exportLabels(dumpPath, keyPath, outDir, day) {
1906
1906
  function reportExport(path, out, allowed) {
1907
1907
  if ("by_answerer" in out) {
1908
1908
  say(
1909
- `wrote ${path}: ${t2(out.by_answerer).map(([who, t13]) => `${who}: ${completeLine(t13)}`).join("; ")}`
1909
+ `wrote ${path}: ${entries(out.by_answerer).map(([who, t]) => `${who}: ${completeLine(t)}`).join("; ")}`
1910
1910
  );
1911
1911
  reportAnswerers(out, allowed);
1912
1912
  } else {
@@ -1954,7 +1954,7 @@ var usage = () => {
1954
1954
  };
1955
1955
  var today = () => {
1956
1956
  const d = /* @__PURE__ */ new Date();
1957
- const two = (n3) => String(n3).padStart(2, "0");
1957
+ const two = (n) => String(n).padStart(2, "0");
1958
1958
  return `${String(d.getFullYear())}-${two(d.getMonth() + 1)}-${two(d.getDate())}`;
1959
1959
  };
1960
1960
  var ARITY = {
@@ -1994,9 +1994,9 @@ function cli(argv) {
1994
1994
  try {
1995
1995
  main(argv);
1996
1996
  return { status: 0, stdout: takePrinted(), stderr: "" };
1997
- } catch (e3) {
1998
- const message = String(Reflect.get(Object(e3), "message"));
1999
- const status = e3 instanceof Refusal ? e3.exitCode : 1;
1997
+ } catch (e) {
1998
+ const message = String(Reflect.get(Object(e), "message"));
1999
+ const status = e instanceof Refusal ? e.exitCode : 1;
2000
2000
  return { status, stdout: takePrinted(), stderr: `${message}
2001
2001
  ` };
2002
2002
  }