@hawkeyexl/manni 4.12.0 → 4.12.2

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 (169) hide show
  1. package/README.md +1 -1
  2. package/dist/{batch-EFSFG6GC.js → batch-RYERHIHR.js} +12 -12
  3. package/dist/{build-NIO3UIWJ.js → build-CSLRUGRM.js} +12 -12
  4. package/dist/{calibrate-6VO7URRV.js → calibrate-4MKBMUPX.js} +13 -13
  5. package/dist/{capture-NMBVJO3C.js → capture-X2DDHVCL.js} +12 -12
  6. package/dist/{check-XMJKH3KV.js → check-3PLTB5JK.js} +13 -13
  7. package/dist/{check-SHOYX2B5.js → check-AFL63XFN.js} +11 -11
  8. package/dist/{check-ZMO3ZLMW.js → check-OSUIOGC6.js} +12 -12
  9. package/dist/{check-Y62BJNC4.js → check-VEUWDCEF.js} +13 -13
  10. package/dist/{chunk-5SID2SVL.js → chunk-3CL5LTYL.js} +4 -4
  11. package/dist/{chunk-F564FHMQ.js → chunk-4OYOMLL6.js} +4 -4
  12. package/dist/{chunk-KGFSPJLD.js → chunk-4RXASF6E.js} +2 -2
  13. package/dist/{chunk-KFGZPVFA.js → chunk-5QOQJW36.js} +4 -4
  14. package/dist/{chunk-QEAGL4V5.js → chunk-6LEY374D.js} +3 -3
  15. package/dist/{chunk-OHUDZRLK.js → chunk-6PE5LRTG.js} +3 -3
  16. package/dist/{chunk-42VFJOAF.js → chunk-7B6Z4WB7.js} +5 -5
  17. package/dist/{chunk-D5Z6B4M7.js → chunk-B26533LD.js} +3 -3
  18. package/dist/{chunk-DLU5FCFT.js → chunk-B3623P3T.js} +7 -7
  19. package/dist/{chunk-AYVKN3PG.js → chunk-BJPDUNK6.js} +4 -4
  20. package/dist/{chunk-2OZF2VUB.js → chunk-CG7QUXY4.js} +2 -2
  21. package/dist/{chunk-AANUY4BH.js → chunk-EWF7IS7J.js} +2 -2
  22. package/dist/{chunk-KMORGMCW.js → chunk-FVU7DSNW.js} +4 -4
  23. package/dist/{chunk-QDC7JPFG.js → chunk-GPWUGBUA.js} +4 -4
  24. package/dist/{chunk-3BRJCQPY.js → chunk-GSGQ5H2E.js} +3 -3
  25. package/dist/{chunk-HDPN46JP.js → chunk-HCRAOWTM.js} +2 -2
  26. package/dist/{chunk-24AJK2RG.js → chunk-HTRQG5NG.js} +3 -3
  27. package/dist/{chunk-DHGB4JBG.js → chunk-I6HHORG5.js} +2 -2
  28. package/dist/{chunk-DHGB4JBG.js.map → chunk-I6HHORG5.js.map} +1 -1
  29. package/dist/{chunk-SGR7ZAVE.js → chunk-ICYZB7XN.js} +3 -3
  30. package/dist/{chunk-D6SELXQ2.js → chunk-JWR4CQQX.js} +5 -5
  31. package/dist/{chunk-CH6IOGXV.js → chunk-K5VEKLPC.js} +7 -7
  32. package/dist/{chunk-QNDDPXFR.js → chunk-LJDPJIA4.js} +2 -2
  33. package/dist/{chunk-2UJZXVHR.js → chunk-LVZH7NOT.js} +6 -6
  34. package/dist/{chunk-STPGIKPY.js → chunk-LZB4RI2I.js} +2 -2
  35. package/dist/{chunk-ANPIIYRH.js → chunk-MF52CQFT.js} +4 -4
  36. package/dist/{chunk-VFAKGIDG.js → chunk-MGKF5JK2.js} +2 -2
  37. package/dist/{chunk-RGLFV4KO.js → chunk-MJ4RYNX7.js} +2 -2
  38. package/dist/{chunk-UXMCHBOJ.js → chunk-MTGHZAJK.js} +2 -2
  39. package/dist/{chunk-G3MBUL5M.js → chunk-MVEFZ7GR.js} +3 -3
  40. package/dist/{chunk-IZXN3WI6.js → chunk-MZFLLTM3.js} +2 -2
  41. package/dist/{chunk-NZ6KSHFD.js → chunk-NMHN27JT.js} +7 -7
  42. package/dist/{chunk-IQQAJROD.js → chunk-NUJNMLC4.js} +3 -3
  43. package/dist/{chunk-QMY57PVW.js → chunk-OTXH4MR3.js} +2 -2
  44. package/dist/{chunk-4WJTURRO.js → chunk-QGBVK2QG.js} +6 -6
  45. package/dist/{chunk-DGRLHDM4.js → chunk-REQ26XDQ.js} +11 -7
  46. package/dist/chunk-REQ26XDQ.js.map +1 -0
  47. package/dist/{chunk-SMHAYK6I.js → chunk-SHE3O6RA.js} +2 -2
  48. package/dist/{chunk-FKAZUZQU.js → chunk-STPMEFUF.js} +3 -3
  49. package/dist/{chunk-DDILEF5F.js → chunk-TVNQVKFE.js} +35 -11
  50. package/dist/chunk-TVNQVKFE.js.map +1 -0
  51. package/dist/{chunk-UUCCV3SI.js → chunk-TW7VHI7E.js} +2 -2
  52. package/dist/{chunk-JSSM7VVV.js → chunk-USKCD6KW.js} +3 -3
  53. package/dist/{chunk-GQ3KRY3B.js → chunk-WLK3NQBE.js} +3 -3
  54. package/dist/{chunk-4Q24OYI3.js → chunk-XJNSLAIS.js} +4 -4
  55. package/dist/{chunk-QSIXNTRV.js → chunk-XVTA5NY7.js} +2 -2
  56. package/dist/{chunk-U22TOL5Y.js → chunk-YZLATDUG.js} +10 -10
  57. package/dist/{chunk-PS257NIU.js → chunk-ZWRDNSBU.js} +6 -6
  58. package/dist/{cli-EDQPQOCE.js → cli-AFXWWN6L.js} +31 -31
  59. package/dist/{cli-6R4W3HAH.js → cli-BDXZ3W2T.js} +15 -15
  60. package/dist/{cli-UW2K5Z5J.js → cli-DJBJ4OL4.js} +19 -19
  61. package/dist/{cli-OJKFXQOM.js → cli-F6ND2GHJ.js} +2 -2
  62. package/dist/{cli-XXTNPPKB.js → cli-HRG2VBX3.js} +8 -8
  63. package/dist/{cli-GBF76EXT.js → cli-I6XV26IB.js} +13 -13
  64. package/dist/{cli-MQYCF3SR.js → cli-L7BAJOBA.js} +16 -16
  65. package/dist/{cli-PHZAO4LZ.js → cli-PJBWHMN5.js} +2 -2
  66. package/dist/{cli-BOMA2FMP.js → cli-Q55R5NBB.js} +9 -9
  67. package/dist/{cli-PTKFFNOW.js → cli-SPSMV5HE.js} +15 -15
  68. package/dist/{cli-4CR7QIOK.js → cli-VPDOX2TG.js} +13 -13
  69. package/dist/cli.js +14 -14
  70. package/dist/docmeta.js +8 -8
  71. package/dist/{github-6VQKSB67.js → github-Q77LDVTG.js} +13 -13
  72. package/dist/{github-RBSEM7ZK.js → github-Z7A2EYUB.js} +11 -11
  73. package/dist/index.d.ts +4 -1
  74. package/dist/index.js +35 -35
  75. package/dist/{json-PU2HLHDQ.js → json-S5CTDJCD.js} +11 -11
  76. package/dist/{labels-SJNSOPBI.js → labels-Q6MO5FNB.js} +10 -10
  77. package/dist/{lint-KIVTHLGU.js → lint-S2RE4FG7.js} +11 -11
  78. package/dist/{list-RDEJDDJF.js → list-LP2T76ZS.js} +11 -11
  79. package/dist/{list-SUTDWL2J.js → list-QRE5U3TM.js} +11 -11
  80. package/dist/{page-UMAA3NCM.js → page-5DQBE6MA.js} +10 -10
  81. package/dist/{prepare-3I3LOXXD.js → prepare-OB5MQFYH.js} +11 -11
  82. package/dist/{pretty-ANLRHU4O.js → pretty-2FANALZN.js} +11 -11
  83. package/dist/{pretty-Q3ZFKOR7.js → pretty-XX67RU3Y.js} +12 -12
  84. package/dist/{reporters-ILT36CIH.js → reporters-3PBYBFK6.js} +4 -4
  85. package/dist/{reporters-PNDLWT6K.js → reporters-43HFOITQ.js} +10 -10
  86. package/dist/{run-QXCK33Z4.js → run-2KL72ZE6.js} +11 -11
  87. package/dist/{term-D2N7UN4P.js → term-YIYM7ROH.js} +15 -15
  88. package/dist/{validate-BRUCOT2O.js → validate-ZHNA6TET.js} +5 -5
  89. package/package.json +1 -1
  90. package/plugin/manni/.claude-plugin/plugin.json +1 -1
  91. package/dist/chunk-DDILEF5F.js.map +0 -1
  92. package/dist/chunk-DGRLHDM4.js.map +0 -1
  93. /package/dist/{batch-EFSFG6GC.js.map → batch-RYERHIHR.js.map} +0 -0
  94. /package/dist/{build-NIO3UIWJ.js.map → build-CSLRUGRM.js.map} +0 -0
  95. /package/dist/{calibrate-6VO7URRV.js.map → calibrate-4MKBMUPX.js.map} +0 -0
  96. /package/dist/{capture-NMBVJO3C.js.map → capture-X2DDHVCL.js.map} +0 -0
  97. /package/dist/{check-SHOYX2B5.js.map → check-3PLTB5JK.js.map} +0 -0
  98. /package/dist/{check-XMJKH3KV.js.map → check-AFL63XFN.js.map} +0 -0
  99. /package/dist/{check-ZMO3ZLMW.js.map → check-OSUIOGC6.js.map} +0 -0
  100. /package/dist/{check-Y62BJNC4.js.map → check-VEUWDCEF.js.map} +0 -0
  101. /package/dist/{chunk-5SID2SVL.js.map → chunk-3CL5LTYL.js.map} +0 -0
  102. /package/dist/{chunk-F564FHMQ.js.map → chunk-4OYOMLL6.js.map} +0 -0
  103. /package/dist/{chunk-KGFSPJLD.js.map → chunk-4RXASF6E.js.map} +0 -0
  104. /package/dist/{chunk-KFGZPVFA.js.map → chunk-5QOQJW36.js.map} +0 -0
  105. /package/dist/{chunk-QEAGL4V5.js.map → chunk-6LEY374D.js.map} +0 -0
  106. /package/dist/{chunk-OHUDZRLK.js.map → chunk-6PE5LRTG.js.map} +0 -0
  107. /package/dist/{chunk-42VFJOAF.js.map → chunk-7B6Z4WB7.js.map} +0 -0
  108. /package/dist/{chunk-D5Z6B4M7.js.map → chunk-B26533LD.js.map} +0 -0
  109. /package/dist/{chunk-DLU5FCFT.js.map → chunk-B3623P3T.js.map} +0 -0
  110. /package/dist/{chunk-AYVKN3PG.js.map → chunk-BJPDUNK6.js.map} +0 -0
  111. /package/dist/{chunk-2OZF2VUB.js.map → chunk-CG7QUXY4.js.map} +0 -0
  112. /package/dist/{chunk-AANUY4BH.js.map → chunk-EWF7IS7J.js.map} +0 -0
  113. /package/dist/{chunk-KMORGMCW.js.map → chunk-FVU7DSNW.js.map} +0 -0
  114. /package/dist/{chunk-QDC7JPFG.js.map → chunk-GPWUGBUA.js.map} +0 -0
  115. /package/dist/{chunk-3BRJCQPY.js.map → chunk-GSGQ5H2E.js.map} +0 -0
  116. /package/dist/{chunk-HDPN46JP.js.map → chunk-HCRAOWTM.js.map} +0 -0
  117. /package/dist/{chunk-24AJK2RG.js.map → chunk-HTRQG5NG.js.map} +0 -0
  118. /package/dist/{chunk-SGR7ZAVE.js.map → chunk-ICYZB7XN.js.map} +0 -0
  119. /package/dist/{chunk-D6SELXQ2.js.map → chunk-JWR4CQQX.js.map} +0 -0
  120. /package/dist/{chunk-CH6IOGXV.js.map → chunk-K5VEKLPC.js.map} +0 -0
  121. /package/dist/{chunk-QNDDPXFR.js.map → chunk-LJDPJIA4.js.map} +0 -0
  122. /package/dist/{chunk-2UJZXVHR.js.map → chunk-LVZH7NOT.js.map} +0 -0
  123. /package/dist/{chunk-STPGIKPY.js.map → chunk-LZB4RI2I.js.map} +0 -0
  124. /package/dist/{chunk-ANPIIYRH.js.map → chunk-MF52CQFT.js.map} +0 -0
  125. /package/dist/{chunk-VFAKGIDG.js.map → chunk-MGKF5JK2.js.map} +0 -0
  126. /package/dist/{chunk-RGLFV4KO.js.map → chunk-MJ4RYNX7.js.map} +0 -0
  127. /package/dist/{chunk-UXMCHBOJ.js.map → chunk-MTGHZAJK.js.map} +0 -0
  128. /package/dist/{chunk-G3MBUL5M.js.map → chunk-MVEFZ7GR.js.map} +0 -0
  129. /package/dist/{chunk-IZXN3WI6.js.map → chunk-MZFLLTM3.js.map} +0 -0
  130. /package/dist/{chunk-NZ6KSHFD.js.map → chunk-NMHN27JT.js.map} +0 -0
  131. /package/dist/{chunk-IQQAJROD.js.map → chunk-NUJNMLC4.js.map} +0 -0
  132. /package/dist/{chunk-QMY57PVW.js.map → chunk-OTXH4MR3.js.map} +0 -0
  133. /package/dist/{chunk-4WJTURRO.js.map → chunk-QGBVK2QG.js.map} +0 -0
  134. /package/dist/{chunk-SMHAYK6I.js.map → chunk-SHE3O6RA.js.map} +0 -0
  135. /package/dist/{chunk-FKAZUZQU.js.map → chunk-STPMEFUF.js.map} +0 -0
  136. /package/dist/{chunk-UUCCV3SI.js.map → chunk-TW7VHI7E.js.map} +0 -0
  137. /package/dist/{chunk-JSSM7VVV.js.map → chunk-USKCD6KW.js.map} +0 -0
  138. /package/dist/{chunk-GQ3KRY3B.js.map → chunk-WLK3NQBE.js.map} +0 -0
  139. /package/dist/{chunk-4Q24OYI3.js.map → chunk-XJNSLAIS.js.map} +0 -0
  140. /package/dist/{chunk-QSIXNTRV.js.map → chunk-XVTA5NY7.js.map} +0 -0
  141. /package/dist/{chunk-U22TOL5Y.js.map → chunk-YZLATDUG.js.map} +0 -0
  142. /package/dist/{chunk-PS257NIU.js.map → chunk-ZWRDNSBU.js.map} +0 -0
  143. /package/dist/{cli-EDQPQOCE.js.map → cli-AFXWWN6L.js.map} +0 -0
  144. /package/dist/{cli-6R4W3HAH.js.map → cli-BDXZ3W2T.js.map} +0 -0
  145. /package/dist/{cli-UW2K5Z5J.js.map → cli-DJBJ4OL4.js.map} +0 -0
  146. /package/dist/{cli-OJKFXQOM.js.map → cli-F6ND2GHJ.js.map} +0 -0
  147. /package/dist/{cli-XXTNPPKB.js.map → cli-HRG2VBX3.js.map} +0 -0
  148. /package/dist/{cli-GBF76EXT.js.map → cli-I6XV26IB.js.map} +0 -0
  149. /package/dist/{cli-MQYCF3SR.js.map → cli-L7BAJOBA.js.map} +0 -0
  150. /package/dist/{cli-PHZAO4LZ.js.map → cli-PJBWHMN5.js.map} +0 -0
  151. /package/dist/{cli-BOMA2FMP.js.map → cli-Q55R5NBB.js.map} +0 -0
  152. /package/dist/{cli-PTKFFNOW.js.map → cli-SPSMV5HE.js.map} +0 -0
  153. /package/dist/{cli-4CR7QIOK.js.map → cli-VPDOX2TG.js.map} +0 -0
  154. /package/dist/{github-6VQKSB67.js.map → github-Q77LDVTG.js.map} +0 -0
  155. /package/dist/{github-RBSEM7ZK.js.map → github-Z7A2EYUB.js.map} +0 -0
  156. /package/dist/{json-PU2HLHDQ.js.map → json-S5CTDJCD.js.map} +0 -0
  157. /package/dist/{labels-SJNSOPBI.js.map → labels-Q6MO5FNB.js.map} +0 -0
  158. /package/dist/{lint-KIVTHLGU.js.map → lint-S2RE4FG7.js.map} +0 -0
  159. /package/dist/{list-RDEJDDJF.js.map → list-LP2T76ZS.js.map} +0 -0
  160. /package/dist/{list-SUTDWL2J.js.map → list-QRE5U3TM.js.map} +0 -0
  161. /package/dist/{page-UMAA3NCM.js.map → page-5DQBE6MA.js.map} +0 -0
  162. /package/dist/{prepare-3I3LOXXD.js.map → prepare-OB5MQFYH.js.map} +0 -0
  163. /package/dist/{pretty-ANLRHU4O.js.map → pretty-2FANALZN.js.map} +0 -0
  164. /package/dist/{pretty-Q3ZFKOR7.js.map → pretty-XX67RU3Y.js.map} +0 -0
  165. /package/dist/{reporters-ILT36CIH.js.map → reporters-3PBYBFK6.js.map} +0 -0
  166. /package/dist/{reporters-PNDLWT6K.js.map → reporters-43HFOITQ.js.map} +0 -0
  167. /package/dist/{run-QXCK33Z4.js.map → run-2KL72ZE6.js.map} +0 -0
  168. /package/dist/{term-D2N7UN4P.js.map → term-YIYM7ROH.js.map} +0 -0
  169. /package/dist/{validate-BRUCOT2O.js.map → validate-ZHNA6TET.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  pathKey
4
- } from "./chunk-D5Z6B4M7.js";
4
+ } from "./chunk-B26533LD.js";
5
5
  import {
6
6
  DEFAULT_CAPTURE_DIR,
7
7
  makeRedactor
@@ -230,4 +230,4 @@ export {
230
230
  rollup,
231
231
  writeLedger
232
232
  };
233
- //# sourceMappingURL=chunk-QMY57PVW.js.map
233
+ //# sourceMappingURL=chunk-OTXH4MR3.js.map
@@ -7,10 +7,10 @@ import {
7
7
  loadGraderPlugins,
8
8
  parseNewerThan,
9
9
  urlManifestRefusal
10
- } from "./chunk-NZ6KSHFD.js";
10
+ } from "./chunk-NMHN27JT.js";
11
11
  import {
12
12
  discoverArtifacts
13
- } from "./chunk-UUCCV3SI.js";
13
+ } from "./chunk-TW7VHI7E.js";
14
14
  import {
15
15
  discoverConfig
16
16
  } from "./chunk-OKMTUAWO.js";
@@ -33,7 +33,7 @@ import {
33
33
  externalWriteWarnings,
34
34
  mergeMetaProvenance,
35
35
  offerExternalHomes
36
- } from "./chunk-2OZF2VUB.js";
36
+ } from "./chunk-CG7QUXY4.js";
37
37
  import {
38
38
  keyHome,
39
39
  marksValidator,
@@ -41,12 +41,12 @@ import {
41
41
  readManifestOrEmpty,
42
42
  readManifestValue,
43
43
  spliceManifestValue
44
- } from "./chunk-SMHAYK6I.js";
44
+ } from "./chunk-SHE3O6RA.js";
45
45
  import {
46
46
  DocmetaError,
47
47
  extractFrontmatter,
48
48
  writeFileAtomic
49
- } from "./chunk-RGLFV4KO.js";
49
+ } from "./chunk-MJ4RYNX7.js";
50
50
  import {
51
51
  SEVERITIES
52
52
  } from "./chunk-77AINBYM.js";
@@ -1191,4 +1191,4 @@ export {
1191
1191
  runFill,
1192
1192
  renderFill
1193
1193
  };
1194
- //# sourceMappingURL=chunk-4WJTURRO.js.map
1194
+ //# sourceMappingURL=chunk-QGBVK2QG.js.map
@@ -12,7 +12,7 @@ import {
12
12
  shortCommit,
13
13
  toValidationResult,
14
14
  unitText
15
- } from "./chunk-AYVKN3PG.js";
15
+ } from "./chunk-BJPDUNK6.js";
16
16
  import {
17
17
  ANY_FENCE,
18
18
  CITE_RULES,
@@ -31,7 +31,7 @@ import {
31
31
  sliceLines,
32
32
  sourceRange,
33
33
  spellSource
34
- } from "./chunk-24AJK2RG.js";
34
+ } from "./chunk-HTRQG5NG.js";
35
35
  import {
36
36
  MAX_RANGE_LINES,
37
37
  MOVE_BUDGET_BYTES,
@@ -44,6 +44,7 @@ import {
44
44
  lineSpec,
45
45
  loadExternalMetadata,
46
46
  memberOf,
47
+ mergeExternalMetadata,
47
48
  mergeWithMarks,
48
49
  orphanEntries,
49
50
  orphanError,
@@ -53,7 +54,7 @@ import {
53
54
  spellLines,
54
55
  splitLines,
55
56
  toBodyLines
56
- } from "./chunk-SMHAYK6I.js";
57
+ } from "./chunk-SHE3O6RA.js";
57
58
  import {
58
59
  STDIN_LABEL,
59
60
  STDIN_TOKEN,
@@ -67,7 +68,7 @@ import {
67
68
  resolveTargetSet,
68
69
  settleBaseline,
69
70
  supportedExtensions
70
- } from "./chunk-RGLFV4KO.js";
71
+ } from "./chunk-MJ4RYNX7.js";
71
72
  import {
72
73
  SEVERITIES
73
74
  } from "./chunk-77AINBYM.js";
@@ -1309,9 +1310,10 @@ function sidecars(index, manifests, urls, collections, opts) {
1309
1310
  const keeps = (m) => m.implied === void 0 || ownsKey(m.implied.collection, m.implied.manifest, CITATIONS_KEY, marked);
1310
1311
  const url = urls.find((m) => memberOfCollection(m) && keeps(m));
1311
1312
  if (url !== void 0) throw toError(urlManifestRefusal(opts.configSource, url.collection));
1313
+ const matchOnly = () => mergeExternalMetadata(label, extract(), index, members, base, { encryptionKey: () => opts.key }).joins;
1312
1314
  const mine = manifests.filter((m) => members.includes(m.collection) && keeps(m));
1313
1315
  const [declared, second] = mine;
1314
- if (declared === void 0) return { joins: [] };
1316
+ if (declared === void 0) return { joins: matchOnly() };
1315
1317
  if (second !== void 0) {
1316
1318
  throw toError(twoManifestsRefusal(label, declared.collection, second.collection));
1317
1319
  }
@@ -1413,6 +1415,7 @@ function joinHits() {
1413
1415
  const values = matched.get(join2.field) ?? /* @__PURE__ */ new Set();
1414
1416
  values.add(join2.value);
1415
1417
  matched.set(join2.field, values);
1418
+ if (page.owner === void 0) continue;
1416
1419
  const id = `${join2.field}\0${join2.value}`;
1417
1420
  const hit = seen.get(id) ?? { file: join2.file, labels: [] };
1418
1421
  if (!hit.labels.includes(label)) hit.labels.push(label);
@@ -1498,7 +1501,8 @@ async function prepareRun(opts, action, verb, sources = {}) {
1498
1501
  const sidecars2 = await sidecarsFor(run2, { pages: files.map((file) => resolve3(base, file)) });
1499
1502
  const setupFor = async (label, content) => {
1500
1503
  const page = await sidecars2?.forPage(label, content, forced?.name);
1501
- if (page?.owner === void 0) return { options: pageOptions };
1504
+ if (page === void 0) return { options: pageOptions };
1505
+ if (page.owner === void 0) return { options: pageOptions, sidecar: page };
1502
1506
  return {
1503
1507
  sidecar: page,
1504
1508
  options: {
@@ -1648,4 +1652,4 @@ export {
1648
1652
  sayNotices,
1649
1653
  runCheck
1650
1654
  };
1651
- //# sourceMappingURL=chunk-DGRLHDM4.js.map
1655
+ //# sourceMappingURL=chunk-REQ26XDQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cite/commands/check.ts","../src/cite/core/sources.ts","../src/cite/core/classify.ts","../src/cite/core/git.ts","../src/cite/core/history.ts","../src/cite/core/check-page.ts","../src/cite/core/config.ts","../src/cite/core/sidecar.ts"],"sourcesContent":["/**\n * `manni cite check`: resolve targets, check every page, settle the baseline.\n *\n * The run shape is meta's `validate`: `resolveCiteRun` → `resolveTargetSet` /\n * `assertNonEmpty` → one `checkCitations` per page → `settleBaseline`. One git\n * client and one source index are built for the run and handed to every page,\n * so a thousand pages against one root cost one `git ls-files`. `prepareRun`\n * is the shared front half; `update` runs the same one.\n */\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport {\n isErrorSeverity,\n supportedExtensions,\n type FieldError,\n type FingerprintContext,\n type MetadataExtractor,\n type RunSummary,\n} from \"../../meta/index.js\";\nimport {\n assertNonEmpty,\n extractorByName,\n gitignoreOptions,\n resolveBaselineRequest,\n resolveTargetSet,\n settleBaseline,\n STDIN_LABEL,\n STDIN_TOKEN,\n} from \"../../meta/internal.js\";\nimport { toValidationResult } from \"../core/adapt.js\";\nimport { checkCitations } from \"../core/check-page.js\";\nimport { DEFAULT_CITE_BASELINE_PATH, resolveCiteRun } from \"../core/config.js\";\nimport { GIT_UNAVAILABLE_HISTORY, gitClient } from \"../core/git.js\";\nimport {\n duplicateJoinRefusal,\n ignoredManifestWarning,\n orphanRefusal,\n sidecarsFor,\n type CitationSidecars,\n type PageSidecar,\n} from \"../core/sidecar.js\";\nimport { createSourceCache, sourceIndexFor } from \"../core/sources.js\";\nimport { warn } from \"../../shared/warn.js\";\nimport { CiteError } from \"../errors.js\";\nimport type {\n CheckOptions,\n CheckPageOptions,\n CheckRun,\n CiteRun,\n GitClient,\n PageCitationReport,\n} from \"../types.js\";\nimport { STDIN_REQUIRES_AS } from \"../../shared/cli-options.js\";\n\n/** What `check` and `update` settle before touching a page. */\nexport interface PreparedRun {\n cwd: string;\n run: CiteRun;\n /** Files to process, posix and relative to `run.base`. */\n files: string[];\n gitignoreSkipped: number;\n usingStdin: boolean;\n /** The `--as` extractor, validated. */\n forced?: MetadataExtractor;\n /** What every `checkCitations` call in the run shares: root, key, table, client, index. */\n pageOptions: CheckPageOptions;\n /** The git client every page shares, the one in `pageOptions`. */\n git: GitClient;\n /** The manifests that own `citations`, or `null` when none does. */\n sidecars: CitationSidecars | null;\n /**\n * What this page's manifest supplies, and the options that carry it. One\n * call per page, so a page named by path still finds its sidecar.\n */\n setupFor: (label: string, content: string) => Promise<PageSetup>;\n /** Whether a flag reshaped the input set, which turns the corpus checks off. */\n scopedByFlags: boolean;\n /** The collections a `--collection` run narrowed to; `undefined` for a whole corpus. */\n covered?: string[];\n}\n\n/** One page's manifest entries, and the check options that carry them. */\nexport interface PageSetup {\n options: CheckPageOptions;\n /**\n * Absent when no collection keeps citations in a manifest. Its `owner` is\n * absent when none keeps this page's.\n */\n sidecar?: PageSidecar;\n}\n\n/**\n * The join values pages carried, for the duplicate-join refusal and the\n * orphan check that follows the per-page loop.\n */\nexport interface JoinHits {\n record: (page: PageSidecar, label: string) => void;\n /** Field -> the values loaded pages carried. */\n matched: Map<string, Set<string>>;\n}\n\nexport function joinHits(): JoinHits {\n const matched = new Map<string, Set<string>>();\n const seen = new Map<string, { file: string; labels: string[] }>();\n return {\n matched,\n record(page, label) {\n for (const join of page.joins) {\n const values = matched.get(join.field) ?? new Set<string>();\n values.add(join.value);\n matched.set(join.field, values);\n // cite writes only the citations a manifest keeps, so only those pages collide.\n if (page.owner === undefined) continue;\n const id = `${join.field}\\u0000${join.value}`;\n const hit = seen.get(id) ?? { file: join.file, labels: [] };\n if (!hit.labels.includes(label)) hit.labels.push(label);\n seen.set(id, hit);\n // Two pages behind one entry: the manifest cannot tell them apart,\n // and a write would land on whichever the run reached last.\n if (hit.labels.length > 1) {\n throw new CiteError(\n duplicateJoinRefusal(join.field, join.value, join.file, hit.labels),\n );\n }\n }\n },\n };\n}\n\n/** What a command's sources mean to it, where that is not `check`'s answer. */\nexport interface SourceNeeds {\n /** The run cannot work without them: `--no-check-sources` is refused (`update`). */\n require?: boolean;\n /** The run resolves `src:` paths at all. `false` for `remove`, which edits the page. */\n resolve?: boolean;\n}\n\n/**\n * The front half of a run: which config governs it, which files it covers,\n * and the clients every page shares. `action` is the past-tense verb the\n * empty-set error uses (\"checked\"), `verb` the imperative one (\"check\").\n */\nexport async function prepareRun(\n opts: CheckOptions,\n action: string,\n verb: string,\n sources: SourceNeeds = {},\n): Promise<PreparedRun> {\n const requireSources = sources.require === true;\n const cwd = resolve(opts.cwd ?? process.cwd());\n const run = await resolveCiteRun({\n cwd,\n configPath: opts.configPath,\n noConfig: opts.noConfig,\n inputs: opts.inputs,\n collection: opts.collection,\n root: opts.root,\n onConfigLoaded: opts.onConfigLoaded,\n onNotice: opts.onNotice,\n env: opts.env,\n ...(sources.resolve === false ? { resolvesSources: false } : {}),\n });\n const { config, inputs, base } = run;\n\n const checkSources = opts.checkSources ?? config?.checkSources ?? true;\n if (requireSources && !checkSources) {\n throw new CiteError(`${verb} needs the sources: drop --no-check-sources (or \\`checkSources: false\\`).`);\n }\n if (inputs.length === 0) {\n throw new CiteError(\n `No files to ${verb}. Pass paths/globs, or declare a collection under \\`collections:\\` in manni.config.yaml.`,\n );\n }\n\n const usingStdin = inputs.includes(STDIN_TOKEN);\n const forced = opts.as === undefined ? undefined : extractorByName(opts.as);\n if (opts.as !== undefined && forced === undefined) {\n throw new CiteError(\n `Unknown format \"${opts.as}\". Supported extensions: ${supportedExtensions().join(\", \")}.`,\n );\n }\n if (usingStdin && forced === undefined) {\n throw new CiteError(STDIN_REQUIRES_AS);\n }\n\n const exts = opts.exts ?? forced?.extensions;\n const fileInputs = inputs.filter((input) => input !== STDIN_TOKEN);\n const allowEmpty = opts.allowEmpty ?? config?.allowEmpty;\n // A collection's `exclude:` shapes the collection, so it applies when the\n // inputs came from the collections and never to a path the operator typed.\n // `--exclude` filters either way; the union is deduplicated, first spelling wins.\n const exclude = [\n ...new Set([\n ...(opts.exclude ?? []),\n ...(run.fromCollections ? run.collections.flatMap((c) => c.exclude) : []),\n ]),\n ];\n const { files, gitignoreSkipped } = await resolveTargetSet({\n inputs: fileInputs,\n exts,\n exclude,\n cwd: base,\n allowEmpty,\n ...gitignoreOptions({\n flag: opts.respectGitignore,\n configured: config?.respectGitignore,\n onNotice: opts.onNotice,\n }),\n });\n assertNonEmpty({ files, inputs: fileInputs, usingStdin, allowEmpty, exclude, exts, gitignoreSkipped, action });\n\n // Git is used whenever it is there: on PATH, with the root inside a work\n // tree. Where it is not, the index is a walk and history is off, and a page\n // whose citations wanted history says so (see `checkCitations`).\n const git = opts.gitClient ?? gitClient(run.root);\n // A claim's history is the page's own, so it is read in the repository the\n // page paths resolve from, which is not the sources' under `--root`.\n const pageGit =\n opts.pageGitClient ?? (run.base === run.root ? git : gitClient(run.base));\n const pageOptions: CheckPageOptions = {\n root: run.root,\n checkSources,\n key: run.key,\n severity: config?.severity,\n gitClient: git,\n pageRoot: run.base,\n pageGitClient: pageGit,\n };\n if (checkSources) pageOptions.sourceIndex = await sourceIndexFor(run.root, git);\n\n // The sidecar manifests, read once per run. Membership is every declared\n // collection's, whatever this run selected, so a page given by path still\n // finds the manifest that owns its citations.\n // A `{page}` manifest (0058) is read for exactly the pages this run checks.\n const sidecars = await sidecarsFor(run, { pages: files.map((file) => resolve(base, file)) });\n const setupFor = async (label: string, content: string): Promise<PageSetup> => {\n const page = await sidecars?.forPage(label, content, forced?.name);\n if (page === undefined) return { options: pageOptions };\n if (page.owner === undefined) return { options: pageOptions, sidecar: page };\n return {\n sidecar: page,\n options: {\n ...pageOptions,\n owned: { file: page.owner.file, collection: page.owner.collection },\n ...(page.citations === undefined ? {} : { citations: page.citations }),\n },\n };\n };\n\n // The corpus invariant meta's orphan checks use: any CLI reshaping of the\n // input set means the operator chose to look at part of the corpus, and an\n // entry for the rest is expected rather than orphaned. `--collection` is\n // not such a reshaping; it makes each named collection a corpus of its own.\n const scopedByFlags =\n // The inputs the operator typed, not the collection globs they resolved\n // to: a corpus run has none of the first and all of the second.\n opts.inputs.length > 0 ||\n usingStdin ||\n opts.as !== undefined ||\n opts.exts !== undefined ||\n (opts.exclude !== undefined && opts.exclude.length > 0) ||\n opts.respectGitignore !== undefined;\n const covered = (opts.collection?.length ?? 0) > 0 ? run.collections.map((c) => c.name) : undefined;\n\n return {\n cwd,\n run,\n files,\n gitignoreSkipped,\n usingStdin,\n forced,\n pageOptions,\n git,\n sidecars,\n setupFor,\n scopedByFlags,\n ...(covered === undefined ? {} : { covered }),\n };\n}\n\n/**\n * The manifest entries a corpus run found nothing for, and the stray\n * `{page}` manifests (proposal 0058). A run the CLI narrowed checks nothing:\n * it never claimed to cover the corpus.\n *\n * A whole run, not narrowed by `--collection` either, also warns once for a\n * page's own manifest that `.gitignore` covers: CI checks out the page\n * without it.\n */\nexport async function assertNoOrphans(prepared: PreparedRun): Promise<void> {\n const { sidecars } = prepared;\n if (sidecars === null || prepared.scopedByFlags) return;\n const orphans = sidecars.orphans(prepared.files, prepared.covered);\n if (orphans.length > 0) throw orphanRefusal(orphans);\n if (prepared.covered !== undefined) return;\n for (const file of await sidecars.ignoredManifests(prepared.files)) warn(ignoredManifestWarning(file));\n}\n\n/** The same invariant, for field-joined entries no loaded page matched. */\nexport function assertNoOrphanJoins(prepared: PreparedRun, hits: JoinHits): void {\n const { sidecars } = prepared;\n if (sidecars === null || prepared.scopedByFlags) return;\n const orphans = sidecars.orphanJoins(hits.matched, prepared.covered);\n if (orphans.length > 0) throw orphanRefusal(orphans);\n}\n\n/** Read a resolved target, as the run labelled it. */\nexport function readTarget(run: CiteRun, file: string): Promise<string> {\n return readFile(resolve(run.base, file), \"utf8\");\n}\n\n/**\n * Run-level notices are said once per run, however many pages raised them.\n * `also` is what the run has to say beyond its pages: said after them, and\n * not again when a page already said it.\n */\nexport function sayNotices(\n pages: readonly PageCitationReport[],\n onNotice: CheckOptions[\"onNotice\"],\n also: readonly string[] = [],\n): void {\n const said = new Set<string>();\n for (const notice of [...pages.flatMap((page) => page.notices), ...also]) {\n if (said.has(notice)) continue;\n said.add(notice);\n onNotice?.(notice);\n }\n}\n\nexport async function runCheck(opts: CheckOptions): Promise<CheckRun> {\n const prepared = await prepareRun(opts, \"checked\", \"check\");\n const { cwd, run, files, gitignoreSkipped, usingStdin, forced, pageOptions, git } = prepared;\n await assertNoOrphans(prepared);\n const hits = joinHits();\n // A check writes nothing, so a source read for one page is still true for the next.\n pageOptions.sourceCache = createSourceCache();\n\n const pages: PageCitationReport[] = [];\n const checkOne = async (label: string, content: string): Promise<void> => {\n const setup = await prepared.setupFor(label, content);\n if (setup.sidecar !== undefined) hits.record(setup.sidecar, label);\n pages.push(await checkCitations({ file: label, content, format: forced?.name }, setup.options));\n };\n if (usingStdin) await checkOne(STDIN_LABEL, opts.stdinContent ?? \"\");\n for (const file of files) await checkOne(file, await readTarget(run, file));\n assertNoOrphanJoins(prepared, hits);\n // `--show-diff` wants history whatever the pages carry. With the sources\n // off nothing is classified, so nothing wants git.\n const wantsDiff = opts.showDiff === true && pageOptions.checkSources !== false && !(await git.available());\n sayNotices(pages, opts.onNotice, wantsDiff ? [GIT_UNAVAILABLE_HISTORY] : []);\n\n const results = pages.map(toValidationResult);\n // Fingerprints must not depend on where the command was run from, so they\n // are measured from the config's directory when one governs the run.\n const frame: FingerprintContext = { cwd, base: run.configDir ?? cwd, runBase: run.base };\n const request = resolveBaselineRequest(opts, run.config?.baseline, run.configDir, cwd, {\n current: DEFAULT_CITE_BASELINE_PATH,\n });\n // The ratchet's own not-found error names `meta validate`; this tool's\n // baseline is recorded by its own command, so the advice has to say so.\n if (request !== null && !request.write && !existsSync(request.absPath)) {\n throw new CiteError(\n `Baseline \"${request.label}\" not found. Record one with \\`manni cite check --write-baseline\\`, or drop --baseline.`,\n );\n }\n const { results: reported, baseline } = await settleBaseline(results, request, frame);\n\n const failed = reported.filter((r) => !r.ok).length;\n const count = (keep: (e: FieldError) => boolean): number =>\n reported.reduce((n, r) => n + r.errors.filter(keep).length, 0);\n const warnings = count((e) => e.severity === \"warning\");\n const notices = count((e) => e.severity === \"notice\");\n const summary: RunSummary = {\n files: reported.length,\n passed: reported.length - failed,\n failed,\n errors: count(isErrorSeverity),\n // Omitted at zero, as meta's summary has them, so the JSON shape of a\n // clean run is the one every consumer of `meta validate` already reads.\n ...(warnings > 0 ? { warnings } : {}),\n ...(notices > 0 ? { notices } : {}),\n ...(gitignoreSkipped > 0 ? { gitignoreSkipped } : {}),\n ...(baseline ? { baseline } : {}),\n };\n\n return { results: reported, summary, frame, pages, warnings, notices };\n}\n","/**\n * Where a `src` may resolve to, and how an encrypted source is written and\n * read.\n *\n * Sources resolve through tracked files only (`git ls-files -z`) when git is\n * available, else through a walk that follows no symlinks. Every candidate is\n * realpath-contained in the root, so a committed symlink or a `..` cannot reach\n * outside it. A page is untrusted input to the CI job that checks it.\n *\n * An encrypted source is the path encrypted with the family key in the\n * `cite-src` context (proposal 0045). Reading one decrypts it to the path and\n * then asks the index exactly as a plain path is asked, so a ciphertext is\n * never a way around the tracked-file rule.\n */\nimport fg from \"fast-glob\";\nimport { lstat, readFile, realpath } from \"node:fs/promises\";\nimport { join, sep } from \"node:path\";\nimport { decryptValue, encryptValue } from \"../../shared/encryption.js\";\nimport { CiteError } from \"../errors.js\";\nimport type { GitClient, MissingReason, SourceCache, SourceIndex, SourceRange } from \"../types.js\";\nimport { splitLines } from \"./hash.js\";\nimport { SRC_PATTERN } from \"./range.js\";\n\n/** The one context cite encrypts in, bound as associated data. */\nconst CONTEXT = \"cite-src\";\n\n/** `path` encrypted under `key`: `~` and at least 82 base64url characters. */\nexport function encryptSourcePath(path: string, key: string): string {\n return encryptValue(path, key, CONTEXT);\n}\n\n/**\n * The path an encrypted source holds, or `undefined` when it does not decrypt\n * under `key` in the `cite-src` context, or holds anything but a path a plain\n * `src` could spell. A ciphertext is trusted no further than the page's own\n * paths are.\n */\nexport function decryptSourcePath(token: string, key: string): string | undefined {\n const opened = decryptValue(token, key, CONTEXT);\n if (!opened.ok || typeof opened.value !== \"string\") return undefined;\n const path = opened.value;\n // A bare plain path: no line suffix, and no ciphertext inside a ciphertext.\n if (path.includes(\":\") || path.startsWith(\"~\") || !SRC_PATTERN.test(path)) return undefined;\n return path;\n}\n\nexport interface BuildIndexOptions {\n /** `git ls-files` when this client reports git available; a walk when it does not, or with no client. */\n gitClient?: GitClient;\n}\n\n/** `true` when `real` is `realRoot` itself or lies below it. */\nfunction isUnder(real: string, realRoot: string): boolean {\n return real === realRoot || real.startsWith(realRoot.endsWith(sep) ? realRoot : realRoot + sep);\n}\n\n/**\n * The candidate's posix relative path if it is a regular file whose real\n * location lies under the real root; `undefined` to drop it. A symlink is\n * dropped by `lstat` before it is ever followed; a path that walks out, or a\n * file reached through a symlinked directory, is dropped by the realpath check.\n */\nasync function admit(root: string, realRoot: string, rel: string): Promise<string | undefined> {\n const abs = join(root, rel);\n try {\n const info = await lstat(abs);\n if (!info.isFile()) return undefined;\n const real = await realpath(abs);\n return isUnder(real, realRoot) ? rel : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function candidates(root: string, opts: BuildIndexOptions | undefined): Promise<string[]> {\n const client = opts?.gitClient;\n if (client !== undefined && (await client.available())) {\n return client.lsFiles();\n }\n return fg(\"**/*\", {\n cwd: root,\n onlyFiles: true,\n dot: true,\n followSymbolicLinks: false,\n ignore: [\"**/.git/**\", \"**/node_modules/**\"],\n });\n}\n\nexport async function buildSourceIndex(root: string, opts?: BuildIndexOptions): Promise<SourceIndex> {\n const realRoot = await realpath(root);\n const admitted = await Promise.all(\n (await candidates(root, opts)).map((rel) => admit(root, realRoot, rel)),\n );\n const files = Object.freeze(\n [...new Set(admitted.filter((rel): rel is string => rel !== undefined))].sort(),\n );\n const byPath = new Set(files);\n return {\n files: () => files,\n has: (path) => byPath.has(path),\n };\n}\n\nfunction isEnoent(error: unknown): boolean {\n return typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\";\n}\n\n/**\n * The source index for a run, with a root that is not there refused as a\n * `CiteError`. Every verb that reads sources builds its index here, so the\n * refusal reads the same on each.\n */\nexport async function sourceIndexFor(root: string, client: GitClient): Promise<SourceIndex> {\n try {\n return await buildSourceIndex(root, { gitClient: client });\n } catch (error) {\n if (isEnoent(error)) throw new CiteError(`Root directory not found: ${root}.`);\n throw error;\n }\n}\n\nexport type ReadSourceResult =\n | { kind: \"ok\"; resolvedPath: string; text: string; lines?: readonly string[] }\n | { kind: \"missing\"; reason: MissingReason };\n\n/**\n * The path a range names, whether or not the file is there. An encrypted\n * source is decrypted under `key` first: with no key that is `no-key`, under\n * another key `undecryptable`. Whether the path is tracked and readable is a\n * separate question, which `readSource` asks next; a path that is gone still\n * has history, and that is what a move search reads.\n */\nexport function resolveSourcePath(\n range: SourceRange,\n key?: string,\n): { path: string } | { reason: Extract<MissingReason, \"no-key\" | \"undecryptable\"> } {\n if (!range.encrypted) return { path: range.path };\n if (key === undefined) return { reason: \"no-key\" };\n const path = decryptSourcePath(range.path, key);\n return path === undefined ? { reason: \"undecryptable\" } : { path };\n}\n\n/** An empty cache for one run's `readSource` calls. */\nexport function createSourceCache(): SourceCache {\n return new Map();\n}\n\n/**\n * Read the file a range names. An encrypted source is decrypted under `key`\n * first: with no key it is `no-key`, under another key `undecryptable`. Never\n * reads a path the index does not hold.\n */\nexport async function readSource(\n root: string,\n index: SourceIndex,\n range: SourceRange,\n key?: string,\n cache?: SourceCache,\n): Promise<ReadSourceResult> {\n const resolved = resolveSourcePath(range, key);\n if (\"reason\" in resolved) return { kind: \"missing\", reason: resolved.reason };\n const resolvedPath = resolved.path;\n if (!index.has(resolvedPath)) return { kind: \"missing\", reason: \"untracked\" };\n if (cache === undefined) {\n const text = await readTracked(root, resolvedPath);\n return text === undefined\n ? { kind: \"missing\", reason: \"unreadable\" }\n : { kind: \"ok\", resolvedPath, text };\n }\n const slot = JSON.stringify([root, resolvedPath]);\n let read = cache.get(slot);\n if (read === undefined) {\n read = readTracked(root, resolvedPath).then((text) =>\n text === undefined ? undefined : { text, lines: splitLines(text) },\n );\n cache.set(slot, read);\n }\n const file = await read;\n return file === undefined\n ? { kind: \"missing\", reason: \"unreadable\" }\n : { kind: \"ok\", resolvedPath, text: file.text, lines: file.lines };\n}\n\n/**\n * One tracked file's bytes, or undefined when it cannot be read: a permission\n * error, or a path the diff named that is no longer on disk. A move search\n * skips such a candidate rather than failing the run over it.\n */\nexport async function readTracked(root: string, path: string): Promise<string | undefined> {\n try {\n return await readFile(join(root, path), \"utf8\");\n } catch {\n return undefined;\n }\n}\n","/**\n * Source-side classification of one citation.\n *\n * current: the range hashes to the pin. moved / moved-ambiguous: a window of\n * the same length hashes equal elsewhere (once / more than once); whole-file\n * citations never move. changed: none equal; with a commit and history,\n * the diff and commit subjects are attached (pretty-only). never-true: no\n * window of the range's length anywhere in the file at the commit hashes to\n * the pin, or the path is absent there. The recorded lines are tried first;\n * the rest of the file is searched because `update` rewrites `src` for a move\n * without touching `commit`, so the lines a pin was minted from may sit\n * elsewhere in the file as it was then. A window that matches there is the\n * original for the move search below. missing: the source cannot be read.\n *\n * Move search: with the original text (git could show the commit), candidate\n * offsets are where the first line matches, compared lexically, hashed only on\n * a full match. Without it, a ±2000-line window around the original position\n * first, then the rest of the file under a 64 MiB hashing budget; past the\n * budget the result is `changed` with `truncatedSearch`.\n *\n * Order, as the ladder has it: the move search runs whenever the pin does not\n * hold, and history decides only what a non-match is called. So a pin that\n * never held at its commit but whose bytes sit elsewhere in the file is\n * `moved`, not `never-true`; the search sees the file as it is.\n *\n * Proposal 0055 widens that in two directions, both gated on the original\n * text. A pin that holds nowhere in its own file is looked for in every file\n * that changed in committed history since its commit, so a rename is `moved`\n * with a new path rather than `missing`. And a `changed` end is bracketed by\n * its old first and last line, so the finding names the span they cover now\n * and `update --accept` re-mints there rather than over a stale range. The\n * 64 MiB budget is one counter per citation, spent in ladder order by every\n * search that settles it.\n */\nimport type {\n GitClient,\n PageCitation,\n PageLines,\n SourceCache,\n SourceEnd,\n SourceIndex,\n SourceRange,\n} from \"../types.js\";\nimport {\n MAX_RANGE_LINES,\n MOVE_BUDGET_BYTES,\n findWindows,\n type FindWindowsOptions,\n type SearchBudget,\n} from \"../../shared/pin.js\";\nimport { hashLines, sliceLines, splitLines } from \"./hash.js\";\nimport { formatSrc, lineSpec, sourceRange, spellSource } from \"./range.js\";\nimport { encryptSourcePath, readSource, readTracked, resolveSourcePath } from \"./sources.js\";\n\n// The move search is the shared pin engine's; this path keeps cite's imports working.\nexport { MAX_RANGE_LINES, MOVE_BUDGET_BYTES, MOVE_WINDOW_LINES, findWindows } from \"../../shared/pin.js\";\nexport type { FindWindowsOptions } from \"../../shared/pin.js\";\n\nexport interface ClassifyOptions {\n root: string;\n index: SourceIndex;\n /** History is read through it when it reports git available, and never otherwise. */\n git: GitClient;\n /** The encryption key: decrypts an encrypted source and keys its pin. */\n key?: string;\n /** Hashing budget for the blind move search, in bytes. Default `MOVE_BUDGET_BYTES`. */\n budget?: number;\n /** Source files already read this run, so a source cited many times is read once. */\n cache?: SourceCache;\n}\n\n/**\n * What git could say about the pin at the recorded commit. `unknown` is a\n * file at the commit too large to search under the budget with the pin found\n * nowhere in the part that was: neither true nor never true. `original`\n * carries the cited lines as they were then, which `reencryptCitations` re-keys\n * from when the pin no longer holds today.\n */\nexport type History =\n | { kind: \"none\" }\n | { kind: \"unavailable\" }\n | { kind: \"never-true\" }\n | { kind: \"unknown\" }\n | { kind: \"original\"; lines: string[] };\n\nexport async function historyOf(\n git: GitClient,\n commit: string,\n path: string,\n range: SourceRange,\n pin: string,\n key: string | undefined,\n budget: number | undefined,\n counter?: SearchBudget,\n): Promise<History> {\n const shown = await git.showFile(commit, path);\n if (\"missing\" in shown) {\n return shown.missing === \"commit\" ? { kind: \"unavailable\" } : { kind: \"never-true\" };\n }\n const then = splitLines(shown.text);\n let joined: string | undefined;\n try {\n joined = sliceLines(then, range);\n } catch {\n // The range ran past the end of the file as it was at the commit.\n joined = undefined;\n }\n if (joined !== undefined && hashLines(joined, key) === pin) {\n return { kind: \"original\", lines: joined.split(\"\\n\") };\n }\n\n // Not at the recorded lines. An entry can carry a `commit` older than its\n // `lines`: one pinned by hand, or one an `update` before this rule\n // re-anchored without advancing the commit. So the lines the pin was minted\n // from may sit elsewhere in the file as it was then. Only a pin found\n // nowhere there never held. A whole-file pin has nowhere else to be.\n if (range.start === undefined) return { kind: \"never-true\" };\n const length = (range.end ?? range.start) - range.start + 1;\n const search: FindWindowsOptions = { around: range.start };\n if (budget !== undefined) search.budget = budget;\n if (counter !== undefined) search.counter = counter;\n const found = findWindows(then, length, pin, key, search);\n const [first] = found.starts;\n if (first !== undefined) {\n return { kind: \"original\", lines: then.slice(first - 1, first - 1 + length) };\n }\n return found.truncated ? { kind: \"unknown\" } : { kind: \"never-true\" };\n}\n\n/** One window that hashes to the pin, at the file it was found in. */\nexport interface CrossFileHit {\n path: string;\n /** 1-based start line in that file. */\n start: number;\n}\n\n/**\n * Every file a commit touched that holds the pinned lines. The candidate list\n * is `git diff --name-only <commit> HEAD`, so it is committed changes only;\n * the entry's own file is dropped because the in-file search covered it, and a\n * path the tracked-file index does not hold is dropped exactly as a cited path\n * would be. The bytes come from the working tree, as every other source read\n * does. Each candidate costs its own bytes against the citation's counter, and\n * the `original` lines take `findWindows` down its filtered path, which hashes\n * only a start line whose text already matches.\n */\nexport async function followAcross(\n ask: {\n git: GitClient;\n root: string;\n index: SourceIndex;\n commit: string;\n /** The entry's own path, already searched. */\n own: string;\n pin: string;\n key: string | undefined;\n /** The pinned lines as they were at the commit: the window's length and its filter. */\n original: readonly string[];\n },\n counter: SearchBudget,\n): Promise<{ hits: CrossFileHit[]; truncated: boolean }> {\n const hits: CrossFileHit[] = [];\n const length = ask.original.length;\n if (length < 1 || ask.git.changedSince === undefined) return { hits, truncated: false };\n // Git prints the diff sorted by path, so a search that stops early stops at\n // the same place twice.\n const candidates = (await ask.git.changedSince(ask.commit)).filter(\n (path) => path !== ask.own && ask.index.has(path),\n );\n for (const path of candidates) {\n const text = await readTracked(ask.root, path);\n // A deletion the diff named, a permission error, or a file that went away\n // between the diff and the read: skipped, never an operational error.\n if (text === undefined) continue;\n const bytes = Buffer.byteLength(text, \"utf8\");\n if (bytes > counter.left) return { hits, truncated: true };\n counter.left -= bytes;\n const found = findWindows(splitLines(text), length, ask.pin, ask.key, {\n original: ask.original,\n });\n for (const start of found.starts) hits.push({ path, start });\n }\n return { hits, truncated: false };\n}\n\n/**\n * The span the pinned range's old first and last line cover in the file as it\n * stands: each must sit exactly once, the last at or after the first, and the\n * span no wider than `MAX_RANGE_LINES`, so an accepted span is never a range\n * the schema refuses. Undefined when any of those fails, which leaves the\n * finding exactly what it is without this search.\n */\nexport function spanOf(\n lines: readonly string[],\n original: readonly string[],\n): PageLines | undefined {\n const first = original[0];\n const last = original[original.length - 1];\n if (first === undefined || last === undefined) return undefined;\n const at = onlyLine(lines, first);\n if (at === undefined) return undefined;\n // A one-line pin's first and last line are the same line, so one occurrence\n // serves both ends and the span is that line.\n const to = original.length === 1 ? at : onlyLine(lines, last);\n if (to === undefined || to < at || to - at + 1 > MAX_RANGE_LINES) return undefined;\n return { start: at, end: to };\n}\n\n/** The 1-based line holding exactly this text, or undefined for none or several. */\nfunction onlyLine(lines: readonly string[], text: string): number | undefined {\n let at: number | undefined;\n for (let i = 0; i < lines.length; i++) {\n if (lines[i] !== text) continue;\n if (at !== undefined) return undefined;\n at = i + 1;\n }\n return at;\n}\n\nexport async function classifyCitation(\n entry: PageCitation,\n opts: ClassifyOptions,\n): Promise<SourceEnd> {\n const { citation } = entry;\n const range = sourceRange(citation.source);\n const commit = citation.source[\"commit-sha\"];\n const result: SourceEnd = { src: spellSource(citation.source), status: \"missing\" };\n if (commit !== undefined) result.commitSha = commit;\n\n // A source whose path will not resolve at all names no file to search from,\n // so its verdict is settled here as it always was.\n const resolved = resolveSourcePath(range, opts.key);\n if (\"reason\" in resolved) {\n result.missingReason = resolved.reason;\n return result;\n }\n const path = resolved.path;\n\n // Only an encrypted source carries a keyed pin, and reading one needed the key.\n const key = range.encrypted ? opts.key : undefined;\n const pin = citation.source.integrity;\n\n // The path may be gone, which is a verdict that now waits: `git show` reads\n // the file at the recorded commit rather than from disk, so a rename is\n // still answerable.\n const source = await readSource(opts.root, opts.index, range, opts.key, opts.cache);\n const lines = source.kind === \"ok\" ? (source.lines ?? splitLines(source.text)) : undefined;\n if (source.kind === \"missing\") result.missingReason = source.reason;\n else result.resolvedPath = source.resolvedPath;\n\n if (lines !== undefined) {\n let here: string | undefined;\n try {\n here = hashLines(sliceLines(lines, range), key);\n } catch {\n // The range runs past the end of the file: nothing to compare, so it is\n // `changed`, and the search below has no window of that length to find.\n here = undefined;\n }\n if (here === pin) {\n result.status = \"current\";\n return result;\n }\n }\n\n // One counter for this citation, spent in ladder order by every search below.\n const counter: SearchBudget = { left: opts.budget ?? MOVE_BUDGET_BYTES };\n\n let history: History = { kind: \"none\" };\n if (commit !== undefined && (await opts.git.available())) {\n history = await historyOf(opts.git, commit, path, range, pin, key, opts.budget, counter);\n }\n const original = history.kind === \"original\" ? history.lines : undefined;\n\n /** The new source as the entry spells sources: a ciphertext stays one. */\n const spellAt = (at: string, start?: number, end?: number): string => {\n const written = range.encrypted && opts.key !== undefined ? encryptSourcePath(at, opts.key) : at;\n return formatSrc({ path: written, encrypted: range.encrypted, ...(start === undefined ? {} : { start, end }) });\n };\n\n // A whole-file pin has nowhere to move to inside its file.\n if (lines !== undefined && range.start !== undefined) {\n const start = range.start;\n const end = range.end ?? start;\n const search: FindWindowsOptions = { around: start, counter };\n if (original !== undefined) search.original = original;\n const found = findWindows(lines, end - start + 1, pin, key, search);\n if (found.truncated) result.truncatedSearch = true;\n // The file is the entry's own, so it is spelled as the entry spelled it.\n const spell = (at: number): string =>\n formatSrc({ ...range, start: at, end: at + (end - start) });\n const [only] = found.starts;\n if (found.starts.length === 1 && only !== undefined) {\n result.status = \"moved\";\n result.newSrc = spell(only);\n result.newLines = String(lineSpec({ start: only, end: only + (end - start) }));\n if (range.encrypted) result.resolvedNewPath = path;\n return result;\n }\n if (found.starts.length > 1) {\n result.status = \"moved-ambiguous\";\n result.candidates = found.starts.map(spell);\n return result;\n }\n }\n\n // The pin holds nowhere in its own file. Every file the commit touched is\n // asked the same question, and a hit is a move whatever else is true of the\n // old range.\n if (commit !== undefined && original !== undefined) {\n const across = await followAcross(\n { git: opts.git, root: opts.root, index: opts.index, commit, own: path, pin, key, original },\n counter,\n );\n if (across.truncated) {\n result.truncatedSearch = true;\n result.truncatedAcross = true;\n }\n const width = range.start === undefined ? undefined : original.length - 1;\n const spell = (hit: CrossFileHit): string =>\n width === undefined ? spellAt(hit.path) : spellAt(hit.path, hit.start, hit.start + width);\n // This is the one place a source whose path would not read settles as\n // something other than `missing`. A reason was recorded because the old\n // path was gone; the verdict is no longer `missing`, so it does not\n // travel with it.\n if (across.hits.length > 0) delete result.missingReason;\n const [only] = across.hits;\n if (across.hits.length === 1 && only !== undefined) {\n result.status = \"moved\";\n result.newSrc = spell(only);\n if (width !== undefined) {\n result.newLines = String(lineSpec({ start: only.start, end: only.start + width }));\n }\n if (range.encrypted) result.resolvedNewPath = only.path;\n return result;\n }\n if (across.hits.length > 1) {\n result.status = \"moved-ambiguous\";\n result.candidates = across.hits.map(spell);\n return result;\n }\n }\n\n // The path is gone and the pin is nowhere a commit touched.\n if (lines === undefined) return result;\n\n if (history.kind === \"never-true\") {\n result.status = \"never-true\";\n return result;\n }\n result.status = \"changed\";\n if (history.kind === \"unavailable\") result.historyAvailable = false;\n if (history.kind === \"unknown\") result.truncatedSearch = true;\n if (original !== undefined && commit !== undefined) {\n result.historyAvailable = true;\n result.commitsSince = await opts.git.subjectsSince(commit, path);\n result.diff = await opts.git.diffSince(commit, path);\n // Where the old first and last line sit now. The content between them did\n // change, so the status stands; what the span buys is a diff and an\n // `--accept` over the lines the sentence rests on.\n //\n // A whole-file pin is left out for the reason it never moves inside its\n // own file: it has no range, so it has nothing to grow. Its `original` is\n // the whole file as it was, whose first and last line usually do still sit\n // once each, so without this guard it would gain a `source.lines` it never\n // had and `--accept` would quietly narrow the citation to a range.\n const span = range.start === undefined ? undefined : spanOf(lines, original);\n if (span !== undefined) result.newLines = String(lineSpec(span));\n }\n return result;\n}\n","/**\n * A thin git client. Every call is `execFile(\"git\", args, { cwd: root,\n * windowsHide: true, maxBuffer: 32 MiB })` with `-c core.quotepath=false`,\n * `--end-of-options` before a commit, `--` before a path, and `<commit>:./<path>`\n * for `show` so the path resolves against the root, not the repository top.\n * Results are memoized per (call, commit, path). The commit is validated\n * against the schema's hex pattern by the caller before it reaches here.\n */\nimport { execFile } from \"node:child_process\";\nimport { CiteError } from \"../errors.js\";\nimport type { GitClient, PageCommit, PageHistory, ShownFile } from \"../types.js\";\n\nconst MAX_BUFFER = 32 * 1024 * 1024;\n\n/** Stderr shapes `git show` uses for a revision it does not have. */\nconst NO_COMMIT = /invalid object name|bad revision|unknown revision|bad object/i;\n/**\n * Stderr shapes for a path absent from the tree at a revision. Git uses these\n * for an unknown *full-length* commit too (`path 'x' does not exist in\n * '<40 hex>'`; only an abbreviated unknown commit says \"invalid object name\"),\n * so a path-shaped failure is trusted only once `rev-parse --verify` has said\n * the commit exists. A shallow clone must degrade to \"history unavailable\",\n * never to \"never true\".\n */\nconst NO_PATH = /does not exist in|exists on disk, but not in|path .* does not exist/i;\n\ntype Outcome =\n | { ok: true; stdout: string }\n /** `code` is git's exit status; absent when git could not be run at all. */\n | { ok: false; stderr: string; message: string; code?: number };\n\nfunction run(root: string, args: readonly string[]): Promise<Outcome> {\n return new Promise((resolve) => {\n execFile(\n \"git\",\n [\"-c\", \"core.quotepath=false\", ...args],\n { cwd: root, windowsHide: true, maxBuffer: MAX_BUFFER, encoding: \"utf8\" },\n (error, stdout, stderr) => {\n if (error) {\n const failure: Outcome = { ok: false, stderr, message: error.message };\n if (typeof error.code === \"number\") failure.code = error.code;\n resolve(failure);\n } else resolve({ ok: true, stdout });\n },\n );\n });\n}\n\n/** `git` at `root`, as a client; see the module comment for the call shapes. */\nexport function gitClient(root: string): GitClient {\n const memo = new Map<string, Promise<unknown>>();\n const once = <T>(key: string, compute: () => Promise<T>): Promise<T> => {\n const held = memo.get(key);\n if (held !== undefined) return held as Promise<T>;\n const made = compute();\n memo.set(key, made);\n return made;\n };\n\n const available = (): Promise<boolean> =>\n once(\"available\", async () => (await run(root, [\"rev-parse\", \"--show-toplevel\"])).ok);\n\n const failed = (verb: string, outcome: Extract<Outcome, { ok: false }>): CiteError =>\n new CiteError(`git ${verb} failed: ${outcome.stderr.trim() || outcome.message}`);\n\n /**\n * Whether the repository has the commit. `--verify --quiet` exits 1 for an\n * object it does not have, and that alone is \"no\": any other failure is\n * git itself failing, and reading it as \"no\" would turn a broken checkout\n * into shallow-clone advice.\n */\n /**\n * Whether the repository is shallow. A shallow oldest commit has a parent\n * nobody fetched, so a walk that runs out of commits there has not reached\n * the beginning of anything.\n */\n const shallow = (): Promise<boolean> =>\n once(\"shallow\", async () => {\n const out = await run(root, [\"rev-parse\", \"--is-shallow-repository\"]);\n return out.ok && out.stdout.trim() === \"true\";\n });\n\n const hasCommit = (commit: string): Promise<boolean> =>\n once(`has\\0${commit}`, async () => {\n const out = await run(root, [\"rev-parse\", \"--verify\", \"--quiet\", \"--end-of-options\", `${commit}^{commit}`]);\n if (out.ok) return true;\n if (out.code === 1) return false;\n throw failed(\"rev-parse\", out);\n });\n\n return {\n available,\n\n shallow,\n\n // `merge-base --is-ancestor` exits 0 for yes and 1 for no. For a commit\n // it does not have it exits 128, `Not a valid commit name`, which reads\n // as git failing. So `hasCommit` answers first, and is required rather\n // than an optimization: a commit git lacks is in no history it holds,\n // which is a no, and exactly the pin a deleted branch leaves behind.\n isAncestor: (commit, of) =>\n once(`ancestor\\0${commit}\\0${of}`, async () => {\n if (!(await hasCommit(commit))) return false;\n const out = await run(root, [\"merge-base\", \"--is-ancestor\", \"--end-of-options\", commit, of]);\n if (out.ok) return true;\n if (out.code === 1) return false;\n throw failed(\"merge-base\", out);\n }),\n\n head: () =>\n once(\"head\", async () => {\n if (!(await available())) return null;\n const out = await run(root, [\"rev-parse\", \"HEAD\"]);\n return out.ok ? out.stdout.trim() : null;\n }),\n\n lsFiles: () =>\n once(\"ls-files\", async () => {\n if (!(await available())) return [];\n const out = await run(root, [\"ls-files\", \"-z\"]);\n if (!out.ok) throw failed(\"ls-files\", out);\n return out.stdout.split(\"\\0\").filter((entry) => entry !== \"\");\n }),\n\n showFile: (commit, path) =>\n once(`show\\0${commit}\\0${path}`, async (): Promise<ShownFile> => {\n const out = await run(root, [\"show\", \"--end-of-options\", `${commit}:./${path}`]);\n if (out.ok) return { text: out.stdout };\n if (NO_COMMIT.test(out.stderr)) return { missing: \"commit\" };\n if (NO_PATH.test(out.stderr)) {\n return (await hasCommit(commit)) ? { missing: \"path\" } : { missing: \"commit\" };\n }\n throw failed(\"show\", out);\n }),\n\n subjectsSince: (commit, path) =>\n once(`log\\0${commit}\\0${path}`, async () => {\n const out = await run(root, [\"log\", \"--format=%s\", \"--end-of-options\", `${commit}..HEAD`, \"--\", path]);\n if (!out.ok) throw failed(\"log\", out);\n return out.stdout.split(/\\r?\\n/).filter((line) => line !== \"\");\n }),\n\n // `HEAD` is written out: with no second revision git compares the commit\n // to the working tree, and this list is committed changes only, so a move\n // that is merely saved is never followed into a page (0055 stress test 8).\n changedSince: (commit) =>\n once(`changed\\0${commit}`, async () => {\n if (!(await available())) return [];\n const out = await run(root, [\"diff\", \"--name-only\", \"--end-of-options\", commit, \"HEAD\"]);\n if (!out.ok) throw failed(\"diff\", out);\n return out.stdout.split(/\\r?\\n/).filter((line) => line !== \"\");\n }),\n\n diffSince: (commit, path) =>\n once(`diff\\0${commit}\\0${path}`, async () => {\n const out = await run(root, [\"diff\", \"--end-of-options\", commit, \"--\", path]);\n if (!out.ok) throw failed(\"diff\", out);\n return out.stdout;\n }),\n\n pageCommits: (path, cap) =>\n once(`commits\\0${String(cap)}\\0${path}`, async (): Promise<PageHistory> => {\n if (!(await available())) return { commits: [], shallow: false, truncated: false };\n // One more than the cap, so a list the cap cut short says so rather\n // than reading as a history that simply ended there.\n // `--topo-order`, because the default date order interleaves the\n // lineages either side of a merge. A walk back through an interleaved\n // list reads one branch's commits as if they came before the other's.\n const out = await run(root, [\n \"log\",\n `--format=%H${UNIT}%s`,\n \"--topo-order\",\n `-n${String(cap + 1)}`,\n \"HEAD\",\n \"--\",\n path,\n ]);\n if (!out.ok) throw failed(\"log\", out);\n const commits: PageCommit[] = [];\n for (const line of out.stdout.split(/\\r?\\n/)) {\n if (line === \"\") continue;\n const at = line.indexOf(UNIT);\n if (at === -1) continue;\n commits.push({ sha: line.slice(0, at), subject: line.slice(at + 1) });\n }\n const truncated = commits.length > cap;\n return { commits: commits.slice(0, cap), shallow: await shallow(), truncated };\n }),\n };\n}\n\n/** The separator between a commit's hash and its subject: never in either. */\nconst UNIT = \"\u001f\";\n\n/**\n * What a run says, once, when git is not there and the run wanted it: a\n * citation carries a commit, or `--show-diff` asked for diffs, so history\n * would have been read. Said through `onNotice`; never a finding.\n */\nexport const GIT_UNAVAILABLE_HISTORY =\n \"git is not available here, so citations are checked without history: no never-true, no reanchored claims, no diffs, no commit subjects.\";\n\n/**\n * What a run says, once, when a claim's walk ran out of commits before the\n * pin held: a shallow checkout, or the 256-commit cap. Without the rest of\n * the history a layout change and an edit read the same.\n */\nexport const PAGE_HISTORY_UNAVAILABLE =\n \"the page history ends before the pin held; use fetch-depth: 0 to tell reanchored claims from changed ones\";\n\n/**\n * What `update --recommit` says, once, in a shallow clone. A commit the clone\n * lacks may still be in the history, so only the containment test ran.\n */\nexport const SHALLOW_RECOMMIT =\n \"this clone is shallow, so --recommit re-recorded only commits that do not contain their lines. Fetch full history to check the rest.\";\n\n/** What `add` and `update --accept` say, once, when a commit would have been recorded and git is not there. */\nexport const GIT_UNAVAILABLE_COMMIT = \"git is not available here, so the citation records no commit.\";\n\n/**\n * A client that answers \"no git\": `available()` false, everything else empty.\n * What a caller passes as `gitClient` to run without git where git is there.\n */\nexport function noGit(): GitClient {\n return {\n available: () => Promise.resolve(false),\n head: () => Promise.resolve(null),\n lsFiles: () => Promise.resolve([]),\n showFile: () => Promise.resolve({ missing: \"commit\" }),\n subjectsSince: () => Promise.resolve([]),\n diffSince: () => Promise.resolve(\"\"),\n changedSince: () => Promise.resolve([]),\n pageCommits: () => Promise.resolve({ commits: [], shallow: false, truncated: false }),\n };\n}\n","/**\n * The claim end read against the page's own history. Proposal 0053 is the\n * record, and the source end's `historyOf` is the shape it follows.\n *\n * A claim that no longer holds says nothing on its own: the pin is a hash, and\n * 0044 chose never to copy the text. So the baseline is derived. It is the\n * newest commit whose page still held the pinned text, found by walking the\n * commits that touched the page, newest first. Nothing is stored, so a squash,\n * a rebase or an uncommitted page cannot make it wrong.\n *\n * With a baseline there are three strings, each normalized the same way.\n * `W0` is the text the pin covered then, `W1` the text the anchor covers now,\n * and `P0` the whole page body then. The claim is **reanchored** when `W0`\n * sits inside `W1` and `W1` sits inside `P0`: every word the pin covered is\n * still there, and every word the claim covers now was on the page already.\n * Anything else is **changed**, which is what the first condition catches for\n * an edit inside the claim and the second for a sentence added beside it.\n */\nimport type {\n ClaimEnd,\n GitClient,\n InlineStatement,\n PageCitation,\n PageCitations,\n PageLines,\n} from \"../types.js\";\nimport { spellLines, toBodyLines } from \"../../shared/pin.js\";\nimport { claimEnd } from \"./claims.js\";\nimport { hashLines, splitLines } from \"./hash.js\";\nimport { readPage } from \"./page.js\";\nimport { parseLines } from \"./range.js\";\nimport { misplacedMarkerAt, movedUnit, unitText } from \"./reanchor.js\";\nimport { shortCommit } from \"./spell.js\";\nimport { ANY_FENCE, isMarkerLine } from \"./statements.js\";\n\n/**\n * How many commits that touched the page one walk reads. A page with a long\n * history stops here, and the run says the history ended before the pin held.\n */\nexport const MAX_PAGE_COMMITS = 256;\n\n/** A page's marker-only lines dropped: the lines whose words a claim is made of. */\nexport function stripMarkers(lines: readonly string[], format: string): string[] {\n return lines.filter((line) => !isMarkerLine(line, format));\n}\n\n/**\n * The words a span of lines holds: marker-only lines dropped, then every run\n * of whitespace collapsed to one space and both ends trimmed. Punctuation,\n * emphasis and inline markup are words here, as 0044 stress test 18 has it.\n */\nexport function claimWords(lines: readonly string[], format: string): string {\n return stripMarkers(lines, format).join(\" \").replace(/\\s+/g, \" \").trim();\n}\n\n/**\n * A text split into sentences, each with its whitespace collapsed and its\n * case dropped. What `update --accept` intersects, so a line that now holds\n * wholly other text is refused rather than blessed.\n */\nexport function sentencesOf(text: string): string[] {\n return text\n .split(/(?<=[.!?])\\s+/)\n .map((sentence) => sentence.replace(/\\s+/g, \" \").trim().toLowerCase())\n .filter((sentence) => sentence !== \"\");\n}\n\n/** Whether two texts share at least one sentence. */\nexport function sharesSentence(a: string, b: string): boolean {\n const left = new Set(sentencesOf(a));\n return sentencesOf(b).some((sentence) => left.has(sentence));\n}\n\n/** A text's distinct words, case dropped. Whitespace is the only separator. */\nfunction wordSet(text: string): Set<string> {\n return new Set(\n text\n .toLowerCase()\n .split(/\\s+/)\n .filter((word) => word !== \"\"),\n );\n}\n\n/**\n * How much of `was` the text `now` still holds, from 0 to 1: the size of the\n * two word sets' intersection over `was`'s own size.\n *\n * Intersection over the baseline, not over the union, so the number reads as\n * the share of the claim's words that survived, and a line that grew around\n * the claim is not punished for the words it gained.\n *\n * Distinct words, because a table row's repeated `|` says nothing about\n * whether this is the same statement. A baseline with no words scores 1:\n * there is nothing for the line to have lost.\n */\nexport function wordShare(was: string, now: string): number {\n const left = wordSet(was);\n if (left.size === 0) return 1;\n const right = wordSet(now);\n let held = 0;\n for (const word of left) if (right.has(word)) held++;\n return held / left.size;\n}\n\n/** `true` when `inner`'s words sit inside `outer`'s, in order, at word boundaries. */\nexport function holdsWords(outer: string, inner: string): boolean {\n if (inner === \"\") return true;\n if (outer === inner) return true;\n if (outer.startsWith(`${inner} `)) return true;\n if (outer.endsWith(` ${inner}`)) return true;\n return outer.includes(` ${inner} `);\n}\n\n/**\n * Every run of whole body lines whose words hold `inner`, minimal under\n * containment. The page's words are laid out once with the line each\n * character came from, so a run is read off each occurrence rather than\n * searched for line by line.\n */\nexport function runsHolding(\n lines: readonly string[],\n format: string,\n bodyLine: number,\n inner: string,\n): PageLines[] {\n if (inner === \"\") return [];\n let text = \"\";\n const at: number[] = [];\n for (let n = Math.max(bodyLine, 1); n <= lines.length; n++) {\n const line = lines[n - 1] ?? \"\";\n if (isMarkerLine(line, format)) continue;\n const words = line.replace(/\\s+/g, \" \").trim();\n if (words === \"\") continue;\n if (text !== \"\") {\n text += \" \";\n at.push(n);\n }\n for (let i = 0; i < words.length; i++) at.push(n);\n text += words;\n }\n const out: PageLines[] = [];\n let from = 0;\n for (;;) {\n const found = text.indexOf(inner, from);\n if (found === -1) break;\n from = found + 1;\n const before = found === 0 ? \" \" : text[found - 1];\n const afterAt = found + inner.length;\n const after = afterAt === text.length ? \" \" : text[afterAt];\n if (before !== \" \" || after !== \" \") continue;\n const start = at[found];\n const end = at[afterAt - 1];\n if (start === undefined || end === undefined) continue;\n if (!out.some((span) => span.start === start && span.end === end)) out.push({ start, end });\n }\n // A run that holds another is not minimal: the tighter one is the claim.\n return out.filter(\n (span) =>\n !out.some(\n (other) =>\n (other.start !== span.start || other.end !== span.end) &&\n other.start >= span.start &&\n other.end <= span.end,\n ),\n );\n}\n\n/** What the walk needs to read one entry's history. */\nexport interface ClaimHistoryInput {\n /** The page as it is now: its format, its body line, and the marker. */\n page: PageCitations;\n entry: PageCitation;\n /** The claim end `claimEnd` classified as `changed`. */\n claim: ClaimEnd;\n /** The page's path, as the client below resolves it. */\n path: string;\n git: GitClient;\n /** The manifest that owns the entry, at the path the config declares now. */\n manifest?: string;\n /** Commits to read. Defaults to `MAX_PAGE_COMMITS`. */\n cap?: number;\n}\n\n/**\n * What the page's history says about a claim that no longer holds.\n * `unavailable` is a walk that ran out of commits, so no verdict is safe.\n * `none` is a walk that reached the entry's birth, or a client with no\n * history to read.\n */\nexport type ClaimHistory =\n | { kind: \"unavailable\" }\n | { kind: \"none\" }\n | {\n kind: \"baseline\";\n /** The newest commit whose page held the pin, as the full hash. */\n commit: string;\n /** Subjects of the commits that touched the page after it, newest first. */\n commitsSince: string[];\n /** `W0`: the words the pin covered at the baseline. */\n words: string;\n /** `P0`: the words the whole page body held at the baseline. */\n pageWords: string;\n /** The pinned lines as they were, for the diff. */\n lines: string[];\n /** The file lines they sat at, for the diff's label. */\n at: string;\n };\n\n/** Whether a line closes the window a marker's anchor may reach. */\nfunction bounds(line: string | undefined): boolean {\n return line === undefined || line.trim() === \"\" || ANY_FENCE.test(line);\n}\n\n/** The plain pin over a span of lines, or undefined when the span is not there. */\nfunction pinOf(lines: readonly string[], span: PageLines): string | undefined {\n if (span.start < 1 || span.end > lines.length || span.end < span.start) return undefined;\n return hashLines(lines.slice(span.start - 1, span.end).join(\"\\n\"));\n}\n\n/** Where the pin sat in one older page, or why the walk should stop. */\ntype FoundAt =\n | { kind: \"found\"; span: PageLines; lines: string[] }\n | { kind: \"absent\" }\n /** The marker that anchors the entry is not in that page, so nothing older can hold it. */\n | { kind: \"no-marker\" };\n\n/** One older page, read as this page is read. */\ninterface ThenPage {\n page: PageCitations;\n lines: string[];\n /** The marker naming the entry, for a marker-anchored one. */\n marker?: InlineStatement;\n}\n\n/** An older page, with the marker that named the entry there. */\nfunction readThen(input: ClaimHistoryInput, text: string): ThenPage | undefined {\n const then = readPage(input.page.file, text, { format: input.page.format });\n const lines = splitLines(then.content);\n if (input.entry.citation.claim?.lines !== undefined) return { page: then, lines };\n const id = input.entry.citation.id;\n if (id === undefined) return undefined;\n const marker = then.statements.find(\n (statement) => statement.payload.kind === \"ref\" && statement.payload.ids.includes(id),\n );\n // A marker absent at a commit is looked for no further back: the entry was\n // a claim-lines entry then, or it did not exist.\n if (marker === undefined) return undefined;\n return { page: then, lines, marker };\n}\n\n/**\n * Whether the pin held on an older page, read by the classifier itself, and\n * over which lines.\n *\n * The classifier is what decides, rather than a bare search for the bytes,\n * because the baseline has to be the last moment the page *said* what the pin\n * recorded. A commit where the pinned sentence merely sits somewhere inside\n * the anchor is not that moment, and taking it as the baseline would let a\n * sentence added beside the claim pass condition 2 (0053 stress test 5).\n * `claimEnd` already knows today's anchor rule, the rule PR #43 replaced, and\n * 0054's joined unit, so all three read here.\n */\nfunction anchorHeldAt(input: ClaimHistoryInput, then: ThenPage): FoundAt {\n const pin = input.entry.citation.claim?.integrity;\n if (pin === undefined) return { kind: \"absent\" };\n const was: PageCitation = {\n citation: input.entry.citation,\n origin: input.entry.origin,\n ...(then.marker === undefined ? {} : { marker: then.marker }),\n };\n const split =\n then.marker === undefined\n ? undefined\n : misplacedMarkerAt(then.page, then.lines, then.marker.line, was);\n const end = claimEnd(then.page, was, then.lines, split);\n if (end === null || (end.status !== \"current\" && end.status !== \"moved\")) {\n return { kind: \"absent\" };\n }\n // Which of the two specs held depends on the anchor and the status, so the\n // pin says: it is the one it matches.\n for (const spec of [end.fileLines, end.newFileLines]) {\n const span = spec === undefined ? undefined : parseLines(spec);\n if (span !== undefined && pinOf(then.lines, span) === pin) {\n return { kind: \"found\", span, lines: then.lines.slice(span.start - 1, span.end) };\n }\n }\n // 0054's case: the pin covered the paragraph a misplaced marker splits,\n // whose lines are not one span.\n if (split !== undefined) {\n const text = unitText(then.lines, split);\n if (hashLines(text.join(\"\\n\")) === pin) {\n return { kind: \"found\", span: movedUnit(split), lines: text };\n }\n }\n return { kind: \"absent\" };\n}\n\n/**\n * The bounded window search, for a marker-anchored pin minted under an anchor\n * rule the tool no longer models. The window runs from the marker to the next\n * blank line or fence, the add rule's own anchor window. A span starts on the\n * marker's line, or on any non-blank, non-marker line inside the window, and\n * ends at or before the window's last line. Only a walk that found no commit\n * where the anchor held asks this, so a wider span never outranks an anchor.\n */\nfunction windowHeldAt(input: ClaimHistoryInput, then: ThenPage): FoundAt {\n const pin = input.entry.citation.claim?.integrity;\n const marker = then.marker;\n if (pin === undefined || marker === undefined) return { kind: \"absent\" };\n if (input.entry.citation.quote === true) return { kind: \"absent\" };\n const lines = then.lines;\n let stop = marker.line;\n for (let n = marker.line + 1; n <= lines.length; n++) {\n if (bounds(lines[n - 1])) break;\n stop = n;\n }\n const starts = [marker.line];\n for (let n = marker.line + 1; n <= stop; n++) {\n const line = lines[n - 1] ?? \"\";\n if (line.trim() === \"\" || isMarkerLine(line, then.page.format)) continue;\n starts.push(n);\n }\n for (const start of starts) {\n for (let end = start; end <= stop; end++) {\n if (pinOf(lines, { start, end }) === pin) {\n return { kind: \"found\", span: { start, end }, lines: lines.slice(start - 1, end) };\n }\n }\n }\n return { kind: \"absent\" };\n}\n\n/**\n * Whether the entry is still written down at a commit, which is how the walk\n * knows it has not passed the entry's birth.\n *\n * A manifest-owned entry is asked of the manifest at the path the current\n * config declares. Absent there means no baseline, which is a plainer verdict\n * rather than a wrong one, so the walk stops.\n *\n * A frontmatter entry is asked of the page. A page without the pin is *not*\n * a stop, because either side of a merge is a lineage the other's pins never\n * reached. It only records that the walk saw a page born without the entry.\n */\nasync function stillWritten(\n input: ClaimHistoryInput,\n commit: string,\n pageText: string,\n): Promise<{ stop: boolean; born: boolean }> {\n const pin = input.entry.citation.claim?.integrity;\n if (pin === undefined) return { stop: true, born: true };\n const manifest = input.manifest;\n if (manifest !== undefined) {\n const shown = await input.git.showFile(commit, manifest);\n const held = \"text\" in shown && shown.text.includes(pin);\n return { stop: !held, born: !held };\n }\n const held = pageText.includes(pin);\n return { stop: false, born: !held };\n}\n\n/**\n * The newest commit whose page held the pin, and what it held. Walks the\n * commits that touched the page, newest first, stopping at the entry's birth\n * and at the cap.\n */\nexport async function claimHistory(input: ClaimHistoryInput): Promise<ClaimHistory> {\n const { git, path } = input;\n if (git.pageCommits === undefined) return { kind: \"none\" };\n if (!(await git.available())) return { kind: \"none\" };\n const cap = input.cap ?? MAX_PAGE_COMMITS;\n const history = await git.pageCommits(path, cap);\n const { commits } = history;\n if (commits.length === 0) return { kind: \"none\" };\n\n const format = input.page.format;\n const baselineAt = (index: number, then: ThenPage, found: FoundAt): ClaimHistory => {\n if (found.kind !== \"found\") return { kind: \"none\" };\n const commit = commits[index];\n if (commit === undefined) return { kind: \"none\" };\n return {\n kind: \"baseline\",\n commit: commit.sha,\n commitsSince: commits.slice(0, index).map((c) => c.subject),\n words: claimWords(found.lines, format),\n pageWords: claimWords(then.lines.slice(then.page.bodyLine - 1), format),\n lines: found.lines,\n at: spellLines(found.span),\n };\n };\n\n /** The pages the walk read, so the fallback search does not re-read them. */\n const examined: ThenPage[] = [];\n let ended: \"birth\" | \"unavailable\" | \"cap\" = \"cap\";\n /** Whether any commit the walk read was older than the entry. */\n let born = false;\n for (let i = 0; i < commits.length; i++) {\n const commit = commits[i];\n if (commit === undefined) continue;\n const shown = await git.showFile(commit.sha, path);\n if (!(\"text\" in shown)) {\n // A commit git cannot show is a shallow boundary; a path absent there\n // is the page's own birth.\n ended = shown.missing === \"commit\" ? \"unavailable\" : \"birth\";\n break;\n }\n const then = readThen(input, shown.text);\n if (then === undefined) {\n ended = \"birth\";\n break;\n }\n examined.push(then);\n const found = anchorHeldAt(input, then);\n if (found.kind === \"found\") return baselineAt(i, then, found);\n const written = await stillWritten(input, commit.sha, shown.text);\n if (written.born) born = true;\n if (written.stop) {\n ended = \"birth\";\n break;\n }\n }\n\n // No commit held the pin at its anchor. A pin minted under an anchor rule\n // the tool no longer models still deserves a baseline, so the bounded\n // window search reads the same pages once.\n for (const [i, then] of examined.entries()) {\n const found = windowHeldAt(input, then);\n if (found.kind === \"found\") return baselineAt(i, then, found);\n }\n\n // Only a walk that reached the entry's birth can say the pin never held; a\n // cut-short one says the history is not all there. A walk that read a page\n // the entry was not on yet has reached that birth, wherever in the list it\n // sat, which is what `born` records.\n if (ended === \"birth\" || born) return { kind: \"none\" };\n if (ended === \"unavailable\") return { kind: \"unavailable\" };\n return history.truncated || history.shallow ? { kind: \"unavailable\" } : { kind: \"none\" };\n}\n\n/** A unified diff of the claim's lines, from the baseline to now, with file-line labels. */\nexport function claimDiff(input: {\n file: string;\n commit: string;\n was: { at: string; lines: readonly string[] };\n now: { at: string; lines: readonly string[] };\n}): string {\n const a = input.was.lines;\n const b = input.now.lines;\n let head = 0;\n while (head < a.length && head < b.length && a[head] === b[head]) head++;\n let tail = 0;\n while (\n tail < a.length - head &&\n tail < b.length - head &&\n a[a.length - 1 - tail] === b[b.length - 1 - tail]\n ) {\n tail++;\n }\n const out = [\n `--- ${input.file}@${shortCommit(input.commit)}:${input.was.at}`,\n `+++ ${input.file}:${input.now.at}`,\n ];\n for (const line of a.slice(0, head)) out.push(` ${line}`);\n for (const line of a.slice(head, a.length - tail)) out.push(`-${line}`);\n for (const line of b.slice(head, b.length - tail)) out.push(`+${line}`);\n for (const line of a.slice(a.length - tail)) out.push(` ${line}`);\n return out.join(\"\\n\");\n}\n\n/** What `refineClaim` needs beyond the history it was given. */\nexport interface RefineClaimInput extends Omit<ClaimHistoryInput, \"git\" | \"cap\"> {\n /** The page now, under the hashing rule. */\n lines: readonly string[];\n history: ClaimHistory;\n}\n\n/**\n * The claim end the words test leaves: `reanchored` where only the layout\n * moved, `moved-ambiguous` where the claim's words now sit in several runs,\n * and `changed` with its baseline otherwise.\n */\nexport function refineClaim(input: RefineClaimInput): ClaimEnd {\n const { claim, history, entry, page, lines } = input;\n if (history.kind === \"unavailable\") return { ...claim, historyAvailable: false };\n if (history.kind === \"none\") return claim;\n const format = page.format;\n const base: ClaimEnd = {\n ...claim,\n commitSha: history.commit,\n historyAvailable: true,\n commitsSince: history.commitsSince,\n baselineText: history.lines,\n };\n // The diff is attached whenever there is a baseline, as the source end's\n // is. `pretty` prints it under `--show-diff`, and no other reporter reads it.\n const withDiff = (end: ClaimEnd, now: { at: string; lines: readonly string[] }): ClaimEnd => {\n const diff = claimDiff({\n file: page.file,\n commit: history.commit,\n was: { at: history.at, lines: history.lines },\n now,\n });\n return { ...end, diff };\n };\n\n // A quote pins source code inside a fence, where collapsing whitespace\n // would hide a real change. So its words test is equality on the lines the\n // hashing rule reads, with only marker lines dropped.\n if (entry.citation.quote === true) {\n const now = claim.text ?? [];\n const same =\n stripMarkers(now, format).join(\"\\n\") === stripMarkers(history.lines, format).join(\"\\n\");\n const at = claim.fileLines ?? history.at;\n return withDiff(same ? { ...base, status: \"reanchored\" } : base, { at, lines: now });\n }\n\n // A marker travels with its text, so the span it anchors now is the claim.\n if (entry.citation.claim?.lines === undefined) {\n const now = claim.text ?? [];\n const w1 = claimWords(now, format);\n const at = claim.fileLines ?? history.at;\n const held = holdsWords(w1, history.words) && holdsWords(history.pageWords, w1);\n return withDiff(held ? { ...base, status: \"reanchored\" } : base, { at, lines: now });\n }\n\n const runs = runsHolding(lines, format, page.bodyLine, history.words);\n const [only] = runs;\n if (runs.length > 1) {\n return {\n ...claim,\n status: \"moved-ambiguous\",\n candidates: runs.map((span) => spellLines(toBodyLines(span, page.bodyLine))),\n candidateFileLines: runs.map(spellLines),\n };\n }\n if (only === undefined) {\n return withDiff(base, { at: claim.fileLines ?? history.at, lines: claim.text ?? [] });\n }\n const now = lines.slice(only.start - 1, only.end);\n const w1 = claimWords(now, format);\n if (!holdsWords(history.pageWords, w1)) {\n return withDiff(base, { at: claim.fileLines ?? history.at, lines: claim.text ?? [] });\n }\n return withDiff(\n {\n ...base,\n status: \"reanchored\",\n newLines: spellLines(toBodyLines(only, page.bodyLine)),\n newFileLines: spellLines(only),\n },\n { at: spellLines(only), lines: now },\n );\n}\n","/**\n * `checkCitations`: the programmatic core a docevals `tool:cite` grader calls\n * for one page. Reads the entries and markers, classifies both ends of each\n * citation, applies the severity table, and returns findings whose messages\n * spell sources exactly as the entry spelled them.\n *\n * The claim end is page-side, so it is judged even under `--no-check-sources`,\n * which a public docs checkout runs. The source end needs the files.\n *\n * `quote: true` is settled here. The claim must still be a fenced block\n * (`anchor-invalid`), and the block is faithful when it reproduces the cited\n * lines as pinned (which survives a move and a missing source) or as they are\n * now (a block someone refreshed ahead of a re-mint). Neither: `quote-drift`.\n */\nimport type {\n CheckPageOptions,\n CitationFinding,\n CitationResult,\n CiteRule,\n CiteSeverity,\n ClaimEnd,\n GitClient,\n PageCitation,\n PageCitationReport,\n PageCitations,\n PageLines,\n SourceCache,\n SourceEnd,\n SourceIndex,\n} from \"../types.js\";\nimport { findingsFor, misplacedMessageFor } from \"./adapt.js\";\nimport { misplacedMarkers, type MisplacedMarker } from \"./reanchor.js\";\nimport { spellLines } from \"../../shared/pin.js\";\nimport { classifyCitation, MOVE_BUDGET_BYTES } from \"./classify.js\";\nimport { blockMatches, claimEnd, claimLineNow, claimLinesNow } from \"./claims.js\";\nimport { GIT_UNAVAILABLE_HISTORY, PAGE_HISTORY_UNAVAILABLE, gitClient } from \"./git.js\";\nimport { claimHistory, refineClaim } from \"./history.js\";\nimport { hashLines, sliceLines, splitLines } from \"./hash.js\";\nimport { readPage } from \"./page.js\";\nimport { STDIN_LABEL } from \"../../meta/internal.js\";\nimport { parseSrc, sourceRange, spellSource } from \"./range.js\";\nimport { buildSourceIndex, readSource } from \"./sources.js\";\nimport { resolveSeverity, ruleId } from \"./severity.js\";\nimport { anchoredLines, fenceSpanAt } from \"./statements.js\";\n\nfunction byLine(a: CitationFinding, b: CitationFinding): number {\n return (a.line ?? Number.MAX_SAFE_INTEGER) - (b.line ?? Number.MAX_SAFE_INTEGER);\n}\n\n/** A page-side finding under the configured table: dropped when `off`, else re-levelled. */\nfunction relevel(\n finding: CitationFinding,\n severity: Readonly<Record<CiteRule, CiteSeverity>>,\n): CitationFinding | undefined {\n const level = severity[finding.rule];\n if (level === \"off\") return undefined;\n return { ...finding, severity: level };\n}\n\ninterface QuoteInput {\n page: PageCitations;\n lines: string[];\n root: string;\n index: Parameters<typeof readSource>[1];\n key?: string;\n cache?: SourceCache;\n checkSources: boolean;\n}\n\n/** The cited lines as they are now, or undefined when they cannot be read. */\nasync function citedNow(\n input: QuoteInput,\n source: SourceEnd,\n entry: PageCitation,\n): Promise<string | undefined> {\n const range = sourceRange(entry.citation.source);\n const read = await readSource(input.root, input.index, range, input.key, input.cache);\n if (read.kind === \"missing\") return undefined;\n // After a move the bytes live at the new range; compare against those.\n const at = source.status === \"moved\" && source.newSrc !== undefined ? parseSrc(source.newSrc) : range;\n try {\n return sliceLines(read.lines ?? splitLines(read.text), at);\n } catch {\n return undefined;\n }\n}\n\n/** Whether a block reproduces the citation, as pinned or as the source is now. */\nfunction faithful(\n blockText: string,\n pin: string,\n key: string | undefined,\n now: string | undefined,\n): boolean {\n return hashLines(splitLines(blockText).join(\"\\n\"), key) === pin || (now !== undefined && blockMatches(blockText, now));\n}\n\n/** The lines inside a block's fences, joined as the hashing rule joins them. */\nfunction insideOf(lines: readonly string[], block: PageLines): string {\n return lines.slice(block.start, block.end - 1).join(\"\\n\");\n}\n\n/**\n * The quote check for one entry: where its block is, whether that is still a\n * fenced block, and whether it still reproduces the source. Findings here are\n * `anchor-invalid` (page-side) and `quote-drift` (needs the source).\n */\nasync function quoteFindings(\n input: QuoteInput,\n entry: PageCitation,\n result: CitationResult,\n): Promise<{ rule: CiteRule; message: string; line?: number }[]> {\n const { citation } = entry;\n if (citation.quote !== true || result.anchor === null) return [];\n const id = citation.id;\n const named = (text: string): string => (id === undefined ? text : `${id}: ${text}`);\n const { page } = input;\n\n let block: PageLines | undefined;\n if (result.anchor === \"marker\" && entry.marker !== undefined) {\n block = anchoredLines(page.content, entry.marker.end, page.format, true);\n if (block === undefined) {\n return [\n {\n rule: \"quote-drift\",\n message: \"quote: true, but no fenced block follows the marker\",\n ...(result.markerLine === undefined ? {} : { line: result.markerLine }),\n },\n ];\n }\n } else {\n const at = result.claim === null ? undefined : claimLinesNow(result.claim);\n if (at === undefined) return [];\n const span = fenceSpanAt(page.content, at.start, page.format);\n if (span === undefined || span.end !== at.end) {\n return [\n {\n rule: \"anchor-invalid\",\n message: named(\n `the quote's claim lines ${at.start === at.end ? String(at.start) : `${String(at.start)}-${String(at.end)}`} are no longer a fenced block.`,\n ),\n line: at.start,\n },\n ];\n }\n block = span;\n }\n\n if (!input.checkSources || result.source.status === \"missing\") return [];\n const key = sourceRange(citation.source).encrypted ? input.key : undefined;\n const now = await citedNow(input, result.source, entry);\n const inside = insideOf(input.lines, block);\n if (faithful(inside, citation.source.integrity, key, now)) return [];\n return [\n {\n rule: \"quote-drift\",\n message: \"quote: true, but the fenced block does not reproduce the cited lines\",\n line: block.start,\n },\n ];\n}\n\n/** The marker end of a result: its line, plus its misplacement when it has one. */\nfunction markerEnd(\n entry: PageCitation,\n misplaced: MisplacedMarker | undefined,\n): Pick<CitationResult, \"marker\"> {\n const { marker } = entry;\n if (marker === undefined) return {};\n if (misplaced === undefined) return { marker: { line: marker.line } };\n return {\n marker: {\n line: marker.line,\n misplaced: { unit: spellLines(misplaced.unit), to: misplaced.to },\n },\n };\n}\n\n/** How a citation is anchored, and the page line it anchors to. */\nfunction anchorOf(\n entry: PageCitation,\n claim: ClaimEnd | null,\n page: PageCitations,\n): Pick<CitationResult, \"anchor\" | \"markerLine\" | \"anchorLine\"> {\n const { citation, marker } = entry;\n const hasLines = citation.claim?.lines !== undefined;\n const out: Pick<CitationResult, \"anchor\" | \"markerLine\" | \"anchorLine\"> = { anchor: null };\n if (marker !== undefined) out.markerLine = marker.line;\n // Lines and a marker both is `anchor-invalid`: neither anchor is trusted.\n if (hasLines && marker !== undefined) return out;\n if (hasLines) {\n out.anchor = \"claim\";\n const at = claim === null ? undefined : claimLineNow(claim);\n if (at !== undefined) out.anchorLine = at;\n return out;\n }\n if (marker !== undefined) {\n out.anchor = \"marker\";\n const unit = anchoredLines(page.content, marker.end, page.format, citation.quote === true);\n out.anchorLine = unit?.start ?? marker.line;\n }\n return out;\n}\n\nexport async function checkCitations(\n page: { file: string; content: string; format?: string },\n opts: CheckPageOptions,\n): Promise<PageCitationReport> {\n const readOptions: Parameters<typeof readPage>[2] = {};\n if (page.format !== undefined) readOptions.format = page.format;\n if (opts.citations !== undefined) readOptions.citations = opts.citations;\n if (opts.owned !== undefined) readOptions.owned = opts.owned;\n const read = readPage(page.file, page.content, readOptions);\n const severity = resolveSeverity(opts.severity);\n const client = opts.gitClient ?? gitClient(opts.root);\n // The page's history lives in the page's own repository, which is not the\n // sources' when `--root` sent those to another checkout.\n const pageGit =\n opts.pageGitClient ??\n (opts.pageRoot === undefined || opts.pageRoot === opts.root\n ? client\n : gitClient(opts.pageRoot));\n const checkSources = opts.checkSources !== false;\n const lines = splitLines(read.content);\n\n const results: CitationResult[] = [];\n const findings: CitationFinding[] = [];\n const notices: string[] = [];\n for (const finding of read.findings) {\n const kept = relevel(finding, severity);\n if (kept !== undefined) findings.push(kept);\n }\n\n const index = checkSources\n ? (opts.sourceIndex ?? (await buildSourceIndex(opts.root, { gitClient: client })))\n : undefined;\n const classifyOpts =\n index === undefined\n ? undefined\n : ({\n root: opts.root,\n index,\n git: client,\n ...(opts.key === undefined ? {} : { key: opts.key }),\n ...(opts.sourceCache === undefined ? {} : { cache: opts.sourceCache }),\n } satisfies Parameters<typeof classifyCitation>[1]);\n\n // A quote is judged page-side even with the sources off, so this stands\n // whether or not there is an index; `quoteFindings` reads a source only\n // when `checkSources` says it may.\n const quoteInput: QuoteInput = {\n page: read,\n lines,\n root: opts.root,\n index: index ?? emptyIndex,\n checkSources,\n ...(opts.key === undefined ? {} : { key: opts.key }),\n ...(opts.sourceCache === undefined ? {} : { cache: opts.sourceCache }),\n };\n\n // Every marker line that splits a paragraph, read once for the page: its\n // entry's claim is judged against it, and each one is its own finding.\n const misplaced = misplacedMarkers(read, lines);\n const misplacedAt = new Map(misplaced.map((found) => [found.line, found]));\n\n for (const entry of read.citations) {\n const split = entry.marker === undefined ? undefined : misplacedAt.get(entry.marker.line);\n const claim = await withClaimHistory(\n { page: read, entry, claim: claimEnd(read, entry, lines, split), lines },\n { path: read.file, git: pageGit, ...(opts.pageCommitCap === undefined ? {} : { cap: opts.pageCommitCap }), ...(opts.owned === undefined ? {} : { manifest: opts.owned.file }) },\n );\n const source: SourceEnd =\n classifyOpts === undefined\n ? skippedSource(entry)\n : await classifyCitation(entry, classifyOpts);\n const result: CitationResult = {\n citation: entry.citation,\n origin: entry.origin,\n ...anchorOf(entry, claim, read),\n ...markerEnd(entry, split),\n claim,\n source,\n };\n results.push(result);\n\n for (const found of await quoteFindings(quoteInput, entry, result)) {\n const level = severity[found.rule];\n if (level === \"off\") continue;\n const finding: CitationFinding = {\n rule: found.rule,\n ruleId: ruleId(found.rule),\n severity: level,\n message: found.message,\n src: source.src,\n index: entry.origin.index,\n };\n if (found.line !== undefined) finding.line = found.line;\n if (entry.citation.id !== undefined) finding.id = entry.citation.id;\n findings.push(finding);\n }\n }\n\n // One finding per misplaced marker, so a run of three is three. An orphan\n // in a run is reported too, with no id, beside its `marker-orphan`.\n const misplacedLevel = severity[\"marker-misplaced\"];\n if (misplacedLevel !== \"off\") {\n for (const found of misplaced) {\n const entry = found.entry;\n const finding: CitationFinding = {\n rule: \"marker-misplaced\",\n ruleId: ruleId(\"marker-misplaced\"),\n severity: misplacedLevel,\n message: misplacedMessageFor(entry?.citation.id, {\n line: found.line,\n unit: spellLines(found.unit),\n place: found.place,\n block: found.block,\n }),\n line: found.line,\n };\n if (entry !== undefined) {\n finding.index = entry.origin.index;\n finding.src = spellSource(entry.citation.source);\n if (entry.citation.id !== undefined) finding.id = entry.citation.id;\n }\n findings.push(finding);\n }\n }\n\n findings.push(...findingsFor(results, severity));\n\n // History is read for a citation with a commit, and for every claim that no\n // longer holds, so a page holding either and with no git to read it through\n // says why its verdicts are plainer. With the sources off nothing is\n // classified, but a claim end still is, and it still wants the page's past.\n const wantsSourceHistory =\n checkSources &&\n read.citations.some(({ citation }) => citation.source[\"commit-sha\"] !== undefined);\n const wantsClaimHistory = results.some((r) => r.claim?.status === \"changed\");\n if (wantsSourceHistory && !(await client.available())) notices.push(GIT_UNAVAILABLE_HISTORY);\n else if (wantsClaimHistory && !(await pageGit.available())) {\n notices.push(GIT_UNAVAILABLE_HISTORY);\n }\n // A claim whose walk ran out of commits: the rest of the history would have\n // told a layout change from an edit.\n if (results.some((r) => r.claim?.historyAvailable === false)) {\n notices.push(PAGE_HISTORY_UNAVAILABLE);\n }\n\n const unavailable = results.find((r) => r.source.historyAvailable === false);\n if (unavailable?.source.commitSha !== undefined) {\n notices.push(\n `commit ${unavailable.source.commitSha.slice(0, 7)} not found in history; use fetch-depth: 0 to enable never-true and diffs`,\n );\n }\n // Two forms, because \"the file\" is the wrong noun for a scan across the\n // files a commit touched. A run raises each at most once, and both when it\n // hit both.\n const budget = String(MOVE_BUDGET_BYTES / (1024 * 1024));\n if (results.some((r) => r.source.truncatedSearch === true && r.source.truncatedAcross !== true)) {\n notices.push(\n `a move search hit its ${budget} MiB budget before covering the file; a citation may read changed rather than moved`,\n );\n }\n if (results.some((r) => r.source.truncatedAcross === true)) {\n notices.push(\n `a move search hit its ${budget} MiB budget before covering the files changed since the pin's commit; a citation may read changed or missing rather than moved`,\n );\n }\n\n return {\n file: read.file,\n format: read.format,\n citations: results,\n findings: findings.sort(byLine),\n notices,\n };\n}\n\n/**\n * The claim end read against the page's history, for a claim that no longer\n * holds. Every other status is what it was: the walk runs only where a\n * verdict is in doubt, so a clean corpus costs no git at all.\n */\nasync function withClaimHistory(\n now: {\n page: PageCitations;\n entry: PageCitation;\n claim: ClaimEnd | null;\n lines: readonly string[];\n },\n read: { path: string; git: GitClient; cap?: number; manifest?: string },\n): Promise<ClaimEnd | null> {\n const { claim } = now;\n if (claim === null || claim.status !== \"changed\") return claim;\n // A page read from stdin has no path in the repository, so it has no history.\n if (read.path === STDIN_LABEL) return claim;\n const input = { page: now.page, entry: now.entry, claim, ...read };\n const history = await claimHistory(input);\n return refineClaim({ ...input, lines: now.lines, history });\n}\n\n/** With `--no-check-sources` no file is read, so every source end is `skipped`. */\nfunction skippedSource(entry: PageCitation): SourceEnd {\n const { source } = entry.citation;\n const out: SourceEnd = { src: spellSource(source), status: \"skipped\" };\n if (source[\"commit-sha\"] !== undefined) out.commitSha = source[\"commit-sha\"];\n return out;\n}\n\n/** Stands in where a quote is judged page-side only; nothing is ever read from it. */\nconst emptyIndex: SourceIndex = { files: () => [], has: () => false };\n","/**\n * The `cite:` section of manni.config.yaml, and the run resolution every\n * command shares (meta's rule: positional inputs resolve from cwd, a\n * collection's `paths` from the config directory; `root` and `baseline` are\n * config-dir relative). The document set itself is not a `cite:` key:\n * proposal 0041 put it in the family-level `collections:` list, which the\n * shared loader parses and `resolveCiteRun` selects from. Unknown keys, rules\n * or levels are errors that name the supported keys and never echo a value.\n * Root resolution: `--root` (cwd-relative) > `cite.root` > git root > cwd,\n * with a notice on the last fallback. The encryption key is the family's, not\n * a `cite:` key: `MANNI_ENCRYPTION_KEY` > the top-level `encryptionKey:` >\n * none, resolved in src/shared/encryption-key.ts (proposal 0045).\n */\nimport { resolve } from \"node:path\";\nimport { selectCollections } from \"../../shared/collections.js\";\nimport {\n findConfigFile,\n readConfigFile,\n type ConfigFile,\n type ConfigFileOptions,\n} from \"../../shared/config-file.js\";\nimport { resolveEncryptionKey } from \"../../shared/encryption-key.js\";\nimport { findGitRoot } from \"../../shared/git-root.js\";\nimport { SEVERITIES } from \"../../shared/severity.js\";\nimport { CiteError } from \"../errors.js\";\nimport {\n CITE_RULES,\n type CiteConfig,\n type CiteRule,\n type CiteRun,\n type CiteSeverity,\n type LoadedCiteConfig,\n} from \"../types.js\";\nimport { isCiteRule } from \"./severity.js\";\n\nexport const CITE_SECTION = \"cite\";\n\nexport const DEFAULT_CITE_BASELINE_PATH = \".manni-cite-baseline.json\";\n\n/** The keys `cite:` accepts, in the order the reference table lists them. */\nconst CONFIG_KEYS: readonly (keyof CiteConfig)[] = [\n \"allowEmpty\",\n \"respectGitignore\",\n \"root\",\n \"baseline\",\n \"checkSources\",\n \"severity\",\n];\n\n/**\n * The key the family encryption key replaced (proposal 0045). It keyed cite's\n * own hashed tokens; values are now encrypted under one key every tool reads,\n * so the old key is refused by name rather than called a typo. The message\n * never quotes the value, which was a secret.\n */\nconst SALT_KEY = \"salt\";\nconst saltRefusal = (source: string): string =>\n `${source}: \"salt\" is no longer a cite key. Values are encrypted with a family key: a top-level encryptionKey:, or MANNI_ENCRYPTION_KEY. Run \\`manni key set\\`.`;\n\n/**\n * The levels a rule takes: the family scale, most severe first, then `off`.\n * Built from `SEVERITIES`, so a level the family adds is a level cite takes.\n */\nconst SEVERITY_LEVELS: readonly CiteSeverity[] = [...[...SEVERITIES].reverse(), \"off\"];\n\nfunction isLevel(value: unknown): value is CiteSeverity {\n return typeof value === \"string\" && (SEVERITY_LEVELS as readonly string[]).includes(value);\n}\n\n/**\n * Where the metadata tool's configuration reference documents `collections:`.\n * The literal meta's `config.ts` carries, repeated because that module is\n * meta's own and sibling tools import only its public and family barrels.\n */\nconst CONFIG_REF = \"https://hawkeyexl.github.io/manni/meta/reference/configuration/\";\n\n/**\n * The two keys proposal 0041 moved out of `cite:` and up to the family level.\n * Refused rather than aliased, as meta refuses them: an alias would be a\n * second place to declare a document set that is meant to be declared once.\n */\nconst MOVED_KEYS: readonly string[] = [\"paths\", \"exclude\"];\n\n/**\n * Refuse a moved key before the unknown-key check, which would otherwise call\n * `paths` a typo. Same sentence as meta's, with the section renamed.\n */\nfunction assertNoMovedKeys(raw: Record<string, unknown>, source: string): void {\n for (const key of MOVED_KEYS) {\n if (Object.hasOwn(raw, key)) {\n throw new CiteError(\n `${source}: \"${key}\" is no longer a cite key. Document sets are declared once for every tool, under a top-level collections: list. See ${CONFIG_REF}#collections`,\n );\n }\n }\n}\n\nconst CONFIG_FILE: ConfigFileOptions = {\n section: CITE_SECTION,\n // The citation tool never had a file of its own before the family file.\n legacyNames: [],\n toError: (message) => new CiteError(message),\n};\n\n/**\n * A key the parser does not know is a typo, not a no-op. Dropping it in\n * silence would let `allowEmtpy: true` read as configured and be nothing.\n * `where` is the mapping as the user spells it: `cite` or `cite.severity`.\n */\nfunction rejectUnknownKeys(\n obj: Record<string, unknown>,\n allowed: readonly string[],\n where: string,\n source: string,\n): void {\n for (const key of Object.keys(obj)) {\n if (!allowed.includes(key)) {\n throw new CiteError(\n `Unknown key \"${key}\" under ${where}: in ${source}. Supported keys: ${allowed.join(\", \")}.`,\n );\n }\n }\n}\n\n/**\n * Every type error names the key and the type it wanted, and nothing else.\n * A value can be a secret pasted under the wrong key, and a message that\n * quoted it would put it in a CI log; the same shape for every key keeps that\n * a rule rather than a special case.\n */\nfunction wrongType(key: string, expected: string, source: string): CiteError {\n return new CiteError(`cite.${key} in ${source} must be ${expected}.`);\n}\n\nfunction asBoolean(value: unknown, key: string, source: string): boolean {\n if (typeof value !== \"boolean\") throw wrongType(key, \"a boolean\", source);\n return value;\n}\n\nfunction asString(value: unknown, key: string, source: string): string {\n if (typeof value !== \"string\") throw wrongType(key, \"a string\", source);\n return value;\n}\n\nfunction isMapping(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction parseSeverity(\n value: unknown,\n source: string,\n): Partial<Record<CiteRule, CiteSeverity>> {\n if (!isMapping(value)) throw wrongType(\"severity\", \"a mapping\", source);\n rejectUnknownKeys(value, CITE_RULES, \"cite.severity\", source);\n const severity: Partial<Record<CiteRule, CiteSeverity>> = {};\n for (const [rule, level] of Object.entries(value)) {\n // `rejectUnknownKeys` already settled this; the guard is for the type.\n if (!isCiteRule(rule)) continue;\n if (!isLevel(level)) {\n // A level is not a secret, so a string one is quoted back: `eror` reads\n // as the typo it is. Anything else is described by type only.\n const got = typeof level === \"string\" ? `, not \"${level}\"` : \"\";\n throw new CiteError(\n `cite.severity.${rule} in ${source} must be one of ${SEVERITY_LEVELS.join(\", \")}${got}.`,\n );\n }\n severity[rule] = level;\n }\n return severity;\n}\n\n/**\n * Validate the `cite:` slice of a family file. `raw` is what the loader cut\n * out: `null` for an empty section, which is the same as no keys at all.\n * `source` is the file as the user would name it, for the messages.\n */\nexport function parseCiteConfig(raw: unknown, source: string): CiteConfig {\n if (raw == null) return {};\n if (!isMapping(raw)) {\n throw new CiteError(`cite: in ${source} must be a mapping.`);\n }\n assertNoMovedKeys(raw, source);\n // Before the unknown-key check, which would call it a typo.\n if (Object.hasOwn(raw, SALT_KEY)) throw new CiteError(saltRefusal(source));\n rejectUnknownKeys(raw, CONFIG_KEYS, \"cite\", source);\n const config: CiteConfig = {};\n if (raw.allowEmpty !== undefined)\n config.allowEmpty = asBoolean(raw.allowEmpty, \"allowEmpty\", source);\n if (raw.respectGitignore !== undefined)\n config.respectGitignore = asBoolean(raw.respectGitignore, \"respectGitignore\", source);\n if (raw.root !== undefined) config.root = asString(raw.root, \"root\", source);\n if (raw.baseline !== undefined)\n config.baseline = asString(raw.baseline, \"baseline\", source);\n if (raw.checkSources !== undefined)\n config.checkSources = asBoolean(raw.checkSources, \"checkSources\", source);\n\n if (raw.severity !== undefined) config.severity = parseSeverity(raw.severity, source);\n return config;\n}\n\n/**\n * The family file itself, found as `loadCiteConfig` finds it but before its\n * `cite:` slice is parsed: the text, the section shape and the family keys\n * (`collections:`, `encryptionKey:`), for a caller that needs more than the\n * values, such as a write that puts a key there. `null` when discovery finds\n * nothing.\n */\nexport function readCiteConfigFile(\n explicitPath: string | undefined,\n cwd: string,\n): Promise<ConfigFile | null> {\n return explicitPath\n ? readConfigFile(explicitPath, cwd, CONFIG_FILE)\n : findConfigFile(cwd, CONFIG_FILE);\n}\n\n/**\n * Load the config from an explicit path (an error if missing) or by\n * discovery: cwd and each ancestor up to the nearest `.git` boundary, reading\n * `manni.config.yaml` at its `cite:` key. A family file with neither `cite:`\n * nor `collections:` belongs to a sibling tool and discovery keeps looking;\n * one with `collections:` alone is this tool's config with no options of its\n * own (0041). See src/shared/config-file.ts for the rules. `null` when\n * discovery finds nothing.\n */\nexport async function loadCiteConfig(\n explicitPath?: string,\n cwd: string = process.cwd(),\n): Promise<LoadedCiteConfig | null> {\n const file = await readCiteConfigFile(explicitPath, cwd);\n return file === null ? null : toLoaded(file);\n}\n\n/** A discovered file's `cite:` slice, parsed, with where it came from. */\nfunction toLoaded(file: ConfigFile): LoadedCiteConfig {\n return {\n config: parseCiteConfig(file.value, file.source),\n path: file.path,\n dir: file.dir,\n source: file.source,\n collections: file.collections,\n };\n}\n\nexport interface CiteRunOptions {\n cwd: string;\n /** `-c/--config`. */\n configPath?: string;\n /** `--no-config`: skip discovery and run on the built-in defaults. */\n noConfig?: boolean;\n /**\n * Positional inputs; empty means fall back to the selected collections'\n * `paths:`. The stdin token `-` cancels that implicit fallback like any\n * other input, but never an explicit `--collection`: stdin is no path, so\n * it rides beside the flag and the named collection is still resolved.\n */\n inputs: string[];\n /**\n * `--collection <name>`, repeatable: the collections this run covers. Empty\n * or absent means every declared one, the same thing, because commander's\n * collector hands `[]` over when the flag was never typed.\n */\n collection?: string[];\n /** `--root`, cwd-relative. */\n root?: string;\n onConfigLoaded?: (info: { path: string; dir: string }) => void;\n /** Told once when the root fell back to cwd. */\n onNotice?: (message: string) => void;\n /**\n * Whether the run resolves `src:` paths at all. Default true. `false`\n * silences the notice about where they would resolve from, which `remove`\n * has no use for: it edits a page and never reads a source.\n */\n resolvesSources?: boolean;\n /** Defaults to `process.env`; a test hands in its own. */\n env?: NodeJS.ProcessEnv;\n}\n\n/** The stdin token, repeated so this module does not depend on the file loader above it. */\nconst STDIN = \"-\";\n\n/**\n * Settle what every command core needs before it touches a file: which\n * config governs the run, what to resolve and from where, the root `src:`\n * paths resolve against, and the encryption key.\n */\nexport async function resolveCiteRun(opts: CiteRunOptions): Promise<CiteRun> {\n const cwd = resolve(opts.cwd);\n const env = opts.env ?? process.env;\n\n // `--collection` names something only a config can define, and selects a\n // set the operator did not type, so it composes with neither positional\n // paths nor `--no-config`. The same two sentences meta and a11y use.\n // Stdin is one more input rather than a path, so it rides beside the flag.\n const wanted = opts.collection ?? [];\n // The paths the operator actually typed. Stdin is not one of them, which is\n // what lets a `-` ride beside the flag instead of being refused as a path.\n const typedInputs = opts.inputs.filter((input) => input !== STDIN);\n if (wanted.length > 0 && typedInputs.length > 0) {\n throw new CiteError(\n \"--collection selects a configured collection; it cannot be combined with paths.\",\n );\n }\n\n // `--no-config` wins over an explicit path, as in meta: the CLI cannot\n // supply both, but the cores are public API. It drops the collections with\n // the section: the file the run was told to ignore is where both live.\n const file = opts.noConfig ? null : await readCiteConfigFile(opts.configPath, cwd);\n const loaded = file === null ? null : toLoaded(file);\n if (wanted.length > 0 && loaded === null) {\n throw new CiteError(\"--collection needs a config file to select from.\");\n }\n if (loaded) opts.onConfigLoaded?.({ path: loaded.path, dir: loaded.dir });\n const config = loaded ? loaded.config : null;\n\n // Selected whatever the inputs are: a typed file is still a member of the\n // collections that contain it. An unknown name is the shared helper's error.\n const collections = loaded\n ? selectCollections(loaded.collections, wanted, loaded.source, (message) => new CiteError(message))\n : [];\n\n // One base per run: positional paths are typed from a shell and stay\n // cwd-relative; a collection's `paths:` was written next to the config and\n // resolves there.\n // `--collection` is a request the run has to honour, as in meta: the named\n // collection's pages are resolved even when stdin rides beside the flag.\n // Counting `-` as a path made `cite check - --as markdown --collection\n // pages` check stdin, open no page of the collection, print no finding and\n // exit 0. The implicit fallback is not a request, and a lone `-` cancels it\n // as before: a piped page is a run of its own.\n const fromCollections = wanted.length > 0 || opts.inputs.length === 0;\n const collectionPaths = fromCollections ? collections.flatMap((c) => c.paths) : [];\n // Stdin keeps its typed position; the globs follow it in declaration order.\n const inputs = fromCollections ? [...opts.inputs, ...collectionPaths] : opts.inputs;\n // Only a path needs a base, so it follows the globs when they contributed\n // and stays at the working directory otherwise — stdin included.\n const base = collectionPaths.length > 0 && loaded ? loaded.dir : cwd;\n\n let root: string;\n if (opts.root !== undefined) {\n root = resolve(cwd, opts.root);\n } else if (loaded && config?.root !== undefined) {\n root = resolve(loaded.dir, config.root);\n } else {\n const gitRoot = findGitRoot(cwd);\n if (gitRoot !== null) {\n root = gitRoot;\n } else {\n root = cwd;\n // Said only to a run that will resolve a source against it.\n if (opts.resolvesSources !== false) {\n opts.onNotice?.(`No git root found; resolving src: paths from ${cwd}`);\n }\n }\n }\n\n // The family key, from the environment or the file's top level. A\n // malformed one is refused here, before any page is read.\n const { key, source: keySource } = resolveEncryptionKey({\n env,\n file,\n toError: (message) => new CiteError(message),\n });\n\n return {\n config,\n inputs,\n base,\n collections,\n fromCollections,\n ...(loaded ? { configDir: loaded.dir, configPath: loaded.path, configSource: loaded.source } : {}),\n root,\n key,\n keySource,\n ...(file === null ? {} : { configFile: file }),\n };\n}\n","/**\n * Citations kept outside the page, in an external-metadata manifest a\n * collection declares (proposal 0037, and 0044's \"the sidecar is external\n * metadata\"). No `cite:` key turns this on: a collection whose\n * `externalMetadata:` owns `citations` keeps its pages' entries there.\n *\n * Reading is meta's merge, not a second loader. `loadCitationSidecars` loads\n * every manifest that owns `citations`, and `forPage` merges one page through\n * `mergeExternalMetadata`, so the join rules, the ownership rules and the\n * per-item lines are the ones `meta validate` already applies.\n *\n * Three things are cite's own, because cite *writes* manifests where meta\n * only reads them:\n *\n * - **Membership is decided by every declared collection**, not by the ones\n * `--collection` or the positional paths selected. A page named by path is\n * still a member of the collection that contains it, and its citations are\n * still in that collection's manifest; a run that read frontmatter instead\n * would report every entry as missing and then write a second copy.\n * - **A URL manifest may not own `citations`** (exit 2). cite writes them,\n * and a URL is not somewhere to write; it would also put a private\n * `source.file` in public CI output. A URL manifest with no `keys`\n * (proposal 0068) is refused for the pages whose schemas give it them.\n * - **A page whose collections own `citations` twice is refused** (exit 2),\n * even before either manifest has an entry for it: a writer has to know\n * which file to write to, and picking one would be the tiebreak 0020\n * refuses.\n *\n * `--no-config` never reaches here: with no config there are no collections,\n * so a page's citations are its frontmatter's.\n */\nimport { existsSync } from \"node:fs\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { configMarks, gitIgnored, mergeWithMarks, type PageMarks } from \"../../meta/internal.js\";\nimport {\n classifyRef,\n externalMetadataJoin,\n loadExternalMetadata,\n memberOf,\n mergeExternalMetadata,\n orphanEntries,\n orphanError,\n orphanJoins,\n PATH_JOIN,\n type CollectionConfig,\n type ExternalMetadataConfig,\n type ExternalMetadataEntry,\n type ExternalMetadataIndex,\n type ExternalMetadataJoin,\n type ExtractedMetadata,\n} from \"../../meta/index.js\";\nimport { hasPagePlaceholder, pageManifestPath } from \"../../shared/page-manifest.js\";\nimport { ownsKey } from \"../../shared/collections.js\";\nimport { CiteError } from \"../errors.js\";\nimport type { CitationInput, CiteRun } from \"../types.js\";\nimport { pickExtractor } from \"./page.js\";\n\n/** The one key cite keeps in a manifest. */\nexport const CITATIONS_KEY = \"citations\";\n\nconst toPosix = (path: string): string => path.split(sep).join(\"/\");\n\n/** How a run spells a manifest: relative to its base, posix, like every file label. */\nfunction reportedPath(abs: string, base: string): string {\n const rel = relative(base, abs);\n return rel === \"\" ? \".\" : toPosix(rel);\n}\n\n/** A manifest that owns `citations` for one collection. */\nexport interface CitationManifest {\n /** The collection that declares it. */\n collection: string;\n /** Absolute path of the manifest file. */\n path: string;\n /** The manifest as the run reports it. */\n file: string;\n /** `path`, or the page field the manifest joins on. */\n join: string;\n /**\n * The `{page}` pattern as the config writes it (proposal 0058), present\n * only when each page has a manifest of its own. The page's file is\n * resolved from it, and one that does not exist yet reads as empty and is\n * created by the first write.\n */\n pattern?: string;\n /**\n * The manifest names no `keys` (proposal 0068), so it keeps a page's\n * citations only when the page's schemas mark `citations` external. The\n * declaration, for `ownsKey`.\n */\n implied?: { collection: CollectionConfig; manifest: ExternalMetadataConfig };\n}\n\n/** Where one page's citations are kept, and what the manifest already holds. */\nexport interface PageSidecar {\n /** The manifest that owns this page's citations, when one does. */\n owner?: CitationManifest;\n /**\n * The key under which this page is written in the manifest: its path\n * relative to the config directory, or its value of the join field.\n * Undefined when the manifest joins on a field the page does not carry, so\n * a writer refuses rather than inventing a key.\n */\n entry?: string;\n /** The manifest's entries for this page, when it supplies any. */\n citations?: CitationInput[];\n /**\n * Field-joined entries this page matched, for the orphan check, and for the\n * duplicate-join check when the page has an `owner`.\n */\n joins: readonly ExternalMetadataJoin[];\n}\n\nexport interface CitationSidecars {\n /** The manifests that own `citations`, by collection. */\n manifests: readonly CitationManifest[];\n /** Directory manifest paths and manifest keys resolve from. */\n configDir: string;\n /** Directory the run's file labels are relative to. */\n base: string;\n forPage(label: string, content: string, format?: string): Promise<PageSidecar>;\n /**\n * Manifest entries naming a page this run did not load, under meta's own\n * corpus invariant. `covered` names the collections a `--collection` run\n * narrowed to, or `undefined` for a whole-corpus run.\n */\n orphans(loaded: readonly string[], covered?: readonly string[]): ExternalMetadataEntry[];\n /** Field entries no loaded page matched, same invariant. */\n orphanJoins(\n matched: ReadonlyMap<string, ReadonlySet<string>>,\n covered?: readonly string[],\n ): ExternalMetadataEntry[];\n /**\n * The `{page}` manifests (proposal 0058) of the loaded pages that exist and\n * that `.gitignore` covers, as the run reports them. A checkout would have\n * none of them, so CI would read those pages as citing nothing.\n */\n ignoredManifests(loaded: readonly string[]): Promise<string[]>;\n}\n\nexport interface LoadSidecarOptions {\n /** Every collection the config declares, not only the ones the run selected. */\n collections: readonly CollectionConfig[];\n /** The config file's directory. */\n configDir: string;\n /** Directory the run's file labels are relative to. */\n base: string;\n /** The config file as the user would name it, for the URL refusal. */\n configSource: string;\n /**\n * The run's pages, as absolute paths. A `{page}` manifest (proposal 0058)\n * is read for exactly these; without them it reads nothing.\n */\n pages?: readonly string[];\n /** The family encryption key, for a join field a page holds encrypted. */\n key?: string;\n /** The tool's error class; `CiteError` unless a sibling command says otherwise. */\n toError?: (message: string) => Error;\n /**\n * What a page's schemas mark external (proposal 0068), asked only for a\n * page a manifest with no `keys` may keep citations for.\n */\n marks?: () => Promise<PageMarks | undefined>;\n}\n\n/** `collection <name>: citations cannot come from a URL manifest, because cite writes them.` */\nexport function urlManifestRefusal(source: string, collection: string): string {\n return `${source}: collection ${collection}: ${CITATIONS_KEY} cannot come from a URL manifest, because cite writes them.`;\n}\n\n/** `<page> is in collections a and b, and both keep citations in a manifest.` */\nexport function twoManifestsRefusal(label: string, a: string, b: string): string {\n return `${label} is in collections ${a} and ${b}, and both keep citations in a manifest.`;\n}\n\n/**\n * May this manifest keep `citations`? One whose `keys` name them does. One\n * with no `keys` (proposal 0068) may, for the pages whose schemas mark them\n * external, which `forPage` decides.\n */\nfunction ownsCitations(manifest: ExternalMetadataConfig): boolean {\n return manifest.keys === undefined || manifest.keys.includes(CITATIONS_KEY);\n}\n\n/** An index with no manifest in it, for a run whose only candidates are keyless URL manifests. */\nfunction emptyIndex(): ExternalMetadataIndex {\n return { owners: new Map(), byPath: new Map(), byField: new Map(), entries: [] };\n}\n\n/**\n * Load every manifest that owns `citations`, or `null` when none does — which\n * is every setup that keeps its citations in frontmatter, and costs nothing.\n *\n * Only the citations-owning manifests are loaded. A sibling manifest of the\n * same collection, supplying meta's own keys from a URL, is none of cite's\n * business and is never fetched here.\n */\nexport async function loadCitationSidecars(\n opts: LoadSidecarOptions,\n): Promise<CitationSidecars | null> {\n const toError = opts.toError ?? ((message: string): Error => new CiteError(message));\n const manifests: CitationManifest[] = [];\n /** Keyless URL manifests: never fetched, and refused for a page they would keep citations for. */\n const urls: CitationManifest[] = [];\n const scoped: CollectionConfig[] = [];\n for (const collection of opts.collections) {\n const owning = collection.externalMetadata.filter(ownsCitations);\n if (owning.length === 0) continue;\n const loaded: ExternalMetadataConfig[] = [];\n for (const manifest of owning) {\n const implied = manifest.keys === undefined ? { implied: { collection, manifest } } : {};\n if (classifyRef(manifest.file).kind === \"url\") {\n if (manifest.keys !== undefined) {\n throw toError(urlManifestRefusal(opts.configSource, collection.name));\n }\n urls.push({ collection: collection.name, path: manifest.file, file: manifest.file, join: externalMetadataJoin(manifest), ...implied });\n continue;\n }\n loaded.push(manifest);\n const path = isAbsolute(manifest.file)\n ? manifest.file\n : resolve(opts.configDir, manifest.file);\n manifests.push({\n collection: collection.name,\n path,\n file: reportedPath(path, opts.base),\n join: externalMetadataJoin(manifest),\n ...(hasPagePlaceholder(manifest.file) ? { pattern: manifest.file } : {}),\n ...implied,\n });\n }\n if (loaded.length > 0) scoped.push({ ...collection, externalMetadata: loaded });\n }\n if (manifests.length === 0 && urls.length === 0) return null;\n\n // A keyless URL manifest is never loaded, but a page it would keep\n // citations for is still refused. With no local manifest to load, an empty\n // index lets each page reach that refusal.\n const index =\n (await loadExternalMetadata(scoped, {\n configDir: opts.configDir,\n base: opts.base,\n ...(opts.pages === undefined ? {} : { pages: opts.pages }),\n })) ?? (urls.length > 0 ? emptyIndex() : null);\n if (index === null) return null;\n return sidecars(index, manifests, urls, scoped, opts);\n}\n\nfunction sidecars(\n index: ExternalMetadataIndex,\n manifests: readonly CitationManifest[],\n urls: readonly CitationManifest[],\n collections: readonly CollectionConfig[],\n opts: LoadSidecarOptions,\n): CitationSidecars {\n const toError = opts.toError ?? ((message: string): Error => new CiteError(message));\n const { configDir, base } = opts;\n let marks: Promise<PageMarks | undefined> | undefined;\n const marksOnce = (): Promise<PageMarks | undefined> => (marks ??= opts.marks?.() ?? Promise.resolve(undefined));\n\n /**\n * The manifest a page's citations live in. A concrete `file` is the one\n * manifest the collection declares. A `{page}` pattern (proposal 0058) is\n * a rule, so the page's own file is resolved from its path, and reported\n * relative to the run's base like every other manifest. Everything else\n * about the owner carries through the spread.\n */\n const pageOwner = (owner: CitationManifest, label: string): CitationManifest | undefined => {\n if (owner.pattern === undefined) return owner;\n const resolved = pageManifestPath(owner.pattern, configDir, resolve(base, label));\n // A page above the config directory is a member of nothing, so this is\n // not reached for one; the guard is for the type.\n if (\"outside\" in resolved) return undefined;\n return { ...owner, path: resolved.abs, file: reportedPath(resolved.abs, base) };\n };\n\n const forPage = async (label: string, content: string, format?: string): Promise<PageSidecar> => {\n // Membership over every declared collection: a keyless URL manifest's\n // collection may not be among the ones loaded.\n const declaredMembers = memberOf(opts.collections, configDir, base, label);\n if (declaredMembers.length === 0) return { joins: [] };\n const members = memberOf(collections, configDir, base, label);\n const memberOfCollection = (m: CitationManifest): boolean => declaredMembers.includes(m.collection);\n\n // A manifest with no keys (proposal 0068) keeps the page's citations\n // when the page's schemas mark them external, asked with them in place.\n // This asks over every declared collection, because which manifest owns\n // a page's citations is decided by all of them. The merge below asks\n // again over the collections this run loaded, for the other fields.\n let extracted: ExtractedMetadata | undefined;\n const extract = (): ExtractedMetadata => (extracted ??= pickExtractor(label, format).extract(content, label));\n const candidates = [...manifests, ...urls].filter((m) => m.implied !== undefined && memberOfCollection(m));\n let marked: ReadonlySet<string> | undefined;\n if (candidates.length > 0) {\n const read = await marksOnce();\n const data = extract().data;\n marked =\n read === undefined\n ? undefined\n : await read(label, Object.hasOwn(data, CITATIONS_KEY) ? data : { ...data, [CITATIONS_KEY]: null }, declaredMembers);\n }\n const keeps = (m: CitationManifest): boolean =>\n m.implied === undefined || ownsKey(m.implied.collection, m.implied.manifest, CITATIONS_KEY, marked);\n const url = urls.find((m) => memberOfCollection(m) && keeps(m));\n if (url !== undefined) throw toError(urlManifestRefusal(opts.configSource, url.collection));\n\n // A keyless manifest that keeps none of this page's citations still names\n // the page in its entry. Without the page's joins, that entry would read\n // as an orphan. Unmarked, the merge only matches: nothing is judged.\n const matchOnly = (): readonly ExternalMetadataJoin[] =>\n mergeExternalMetadata(label, extract(), index, members, base, { encryptionKey: () => opts.key }).joins;\n\n // The owning manifest is the page's, decided before any entry is read:\n // two of them is a refusal even when only one has an entry today.\n const mine = manifests.filter((m) => members.includes(m.collection) && keeps(m));\n const [declared, second] = mine;\n if (declared === undefined) return { joins: matchOnly() };\n if (second !== undefined) {\n throw toError(twoManifestsRefusal(label, declared.collection, second.collection));\n }\n const owner = pageOwner(declared, label);\n if (owner === undefined) return { joins: [] };\n\n // The merge judges every field a keyless manifest holds, not only\n // `citations`, so it reads the page's marks with those values in place,\n // as meta's own merge does.\n const readMarks = await marksOnce();\n const merged = await mergeWithMarks(label, extract(), index, members, base, {\n encryptionKey: () => opts.key,\n ...(readMarks === undefined ? {} : { marks: readMarks }),\n });\n\n const out: PageSidecar = { owner, joins: merged.joins };\n if (owner.join === PATH_JOIN) {\n out.entry = toPosix(relative(configDir, resolve(base, label)));\n } else {\n const value = merged.joins.find((j) => j.field === owner.join)?.value;\n // No match: the page's own value of the join field still keys it, so a\n // first `add` can write an entry a later run will match.\n const raw = value ?? extract().data[owner.join];\n if (typeof raw === \"string\" && raw !== \"\") out.entry = raw;\n else if (typeof raw === \"number\" || typeof raw === \"boolean\") out.entry = String(raw);\n }\n\n // The manifest supplied the key exactly when `locate` answers for it;\n // a page carrying its own `citations:` keeps them (the collision is a\n // finding, not a tiebreak), and `locate` then answers `undefined`.\n const where = merged.locate(`/${CITATIONS_KEY}`);\n if (where !== undefined) {\n const supplied: unknown = merged.extracted.data[CITATIONS_KEY];\n const list: unknown[] = Array.isArray(supplied) ? (supplied as unknown[]) : [supplied];\n out.citations = list.map((entry, i) => {\n const at = merged.locate(`/${CITATIONS_KEY}/${String(i)}`);\n const line = (Array.isArray(supplied) ? at?.line : undefined) ?? where.line;\n return {\n entry,\n origin: {\n kind: \"manifest\" as const,\n file: where.file,\n ...(line === undefined ? {} : { line }),\n },\n };\n });\n }\n return out;\n };\n\n const ignoredManifests = async (loaded: readonly string[]): Promise<string[]> => {\n const existing = new Set<string>();\n for (const label of loaded) {\n const members = memberOf(collections, configDir, base, label);\n for (const declared of manifests) {\n if (declared.pattern === undefined || !members.includes(declared.collection)) continue;\n const owner = pageOwner(declared, label);\n if (owner !== undefined && existsSync(owner.path)) existing.add(owner.file);\n }\n }\n if (existing.size === 0) return [];\n const { ignored } = await gitIgnored([...existing], base);\n return [...existing].filter((file) => ignored.has(file));\n };\n\n return {\n manifests,\n configDir,\n base,\n forPage,\n orphans: (loaded, covered) => orphanEntries(index, loaded, base, covered),\n orphanJoins: (matched, covered) => orphanJoins(index, matched, covered),\n ignoredManifests,\n };\n}\n\n/** `<manifest> is covered by .gitignore, so CI checks out a page with no citations.` */\nexport function ignoredManifestWarning(file: string): string {\n return `${file} is covered by .gitignore, so CI checks out a page with no citations.`;\n}\n\n/** The refusal a whole-corpus run raises for a manifest entry naming nothing. */\nexport function orphanRefusal(\n orphans: readonly ExternalMetadataEntry[],\n toError: (message: string) => Error = (m) => new CiteError(m),\n): Error {\n return toError(orphanError(orphans).message);\n}\n\n/**\n * Two pages carrying one `join:` value: the manifest cannot tell them apart,\n * and cite would write one page's entry over the other's. Meta files this as\n * a finding on each document; here it is the run's problem, because the run\n * writes.\n */\nexport function duplicateJoinRefusal(\n field: string,\n value: string,\n file: string,\n labels: readonly string[],\n): string {\n return `${String(labels.length)} pages carry ${field} \"${value}\"; ${file} cannot tell them apart (${labels.join(\", \")}).`;\n}\n\n/**\n * Load the sidecars a resolved run governs; `null` with no config, or no\n * citations manifest. `base` overrides the run's when a command labels its\n * pages from somewhere else — `add` takes one page from the command line and\n * labels it from the working directory, whatever the collections would.\n * `pages` are the run's pages as absolute paths, which a `{page}` manifest\n * (proposal 0058) is read for.\n */\nexport function sidecarsFor(\n run: CiteRun,\n over: {\n base?: string;\n toError?: (message: string) => Error;\n pages?: readonly string[];\n } = {},\n): Promise<CitationSidecars | null> {\n const declared = run.configFile?.collections ?? [];\n if (run.configDir === undefined || declared.length === 0) return Promise.resolve(null);\n // A const, so the narrowing below holds inside the closure.\n const { configPath } = run;\n return loadCitationSidecars({\n // Every declared collection, whatever `--collection` or the paths chose.\n collections: declared,\n configDir: run.configDir,\n base: over.base ?? run.base,\n configSource: run.configSource ?? run.configPath ?? \"the config\",\n ...(run.key === undefined ? {} : { key: run.key }),\n ...(over.toError === undefined ? {} : { toError: over.toError }),\n ...(over.pages === undefined ? {} : { pages: over.pages }),\n // A keyless manifest (proposal 0068) keeps what a page's schemas mark,\n // read from meta's section of the same file.\n ...(configPath === undefined ? {} : { marks: () => configMarks(configPath, run.base) }),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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E,SAAS,IAAI,CAAC;AAAA,EACjC;AAEA,SAAO,EAAE,SAAS,UAAU,SAAS,OAAO,OAAO,UAAU,QAAQ;AACvE;","names":["existsSync","readFile","resolve","candidates","resolve","held","now","w1","resolve","sep","sep","emptyIndex","resolve","candidates","run","join","resolve","run","sidecars","readFile","existsSync"]}
@@ -42,7 +42,7 @@ import {
42
42
  schemaLoadOptions,
43
43
  schemaTrustRoot,
44
44
  writeFileAtomic
45
- } from "./chunk-RGLFV4KO.js";
45
+ } from "./chunk-MJ4RYNX7.js";
46
46
  import {
47
47
  STDIN_LINES_MARKER
48
48
  } from "./chunk-YEUYKR62.js";
@@ -4585,4 +4585,4 @@ export {
4585
4585
  explicitFalse,
4586
4586
  reportConfig
4587
4587
  };
4588
- //# sourceMappingURL=chunk-SMHAYK6I.js.map
4588
+ //# sourceMappingURL=chunk-SHE3O6RA.js.map
@@ -7,7 +7,7 @@ import {
7
7
  CONCEPT_FIELDS,
8
8
  fieldPointer,
9
9
  valueAt
10
- } from "./chunk-PS257NIU.js";
10
+ } from "./chunk-ZWRDNSBU.js";
11
11
  import {
12
12
  STDIN_LABEL,
13
13
  STDIN_TOKEN,
@@ -18,7 +18,7 @@ import {
18
18
  locateFrontmatter,
19
19
  resolveTargetSet,
20
20
  supportedExtensions
21
- } from "./chunk-RGLFV4KO.js";
21
+ } from "./chunk-MJ4RYNX7.js";
22
22
  import {
23
23
  SEVERITIES
24
24
  } from "./chunk-77AINBYM.js";
@@ -3522,4 +3522,4 @@ export {
3522
3522
  valeConfigFor,
3523
3523
  plural
3524
3524
  };
3525
- //# sourceMappingURL=chunk-FKAZUZQU.js.map
3525
+ //# sourceMappingURL=chunk-STPMEFUF.js.map