@hawkeyexl/manni 4.14.0 → 4.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{batch-TKNIUBLK.js → batch-OMDKRGUE.js} +13 -13
- package/dist/{build-6G7PEAG4.js → build-YCY5MUHA.js} +13 -13
- package/dist/{calibrate-BDCXDZV5.js → calibrate-RN2NJ4FS.js} +14 -14
- package/dist/{capture-NQJLZD66.js → capture-2WYROZKA.js} +13 -13
- package/dist/{check-BSB4FF4L.js → check-KRVWHF7E.js} +12 -12
- package/dist/{check-QIZCTAIR.js → check-LVUTWAGR.js} +14 -14
- package/dist/{check-552X5I2J.js → check-MR7IG7IP.js} +14 -14
- package/dist/{check-5HMDJOFP.js → check-OIRJ6OBW.js} +13 -13
- package/dist/{chunk-7PENJOI6.js → chunk-3CSEHHKB.js} +6 -6
- package/dist/{chunk-Y36PNW6J.js → chunk-3EJVJDMX.js} +6 -6
- package/dist/{chunk-V6OCE4ND.js → chunk-3WQMMLIO.js} +7 -7
- package/dist/{chunk-742G2QCV.js → chunk-46OWIAAX.js} +3 -3
- package/dist/{chunk-742G2QCV.js.map → chunk-46OWIAAX.js.map} +1 -1
- package/dist/{chunk-36FJWJSK.js → chunk-476DMDJ5.js} +2 -2
- package/dist/{chunk-7KOWE4F4.js → chunk-4MYW2D2U.js} +8 -8
- package/dist/{chunk-6XFSZCLT.js → chunk-525KMBZS.js} +4 -4
- package/dist/{chunk-ZRQUQS7P.js → chunk-57DHX65T.js} +3 -3
- package/dist/{chunk-PCE7QHXJ.js → chunk-5D24C6WM.js} +6 -1
- package/dist/chunk-5D24C6WM.js.map +1 -0
- package/dist/{chunk-QF7EIRMU.js → chunk-6DYFWAZA.js} +541 -343
- package/dist/chunk-6DYFWAZA.js.map +1 -0
- package/dist/{chunk-7WVWGULD.js → chunk-7EKXSSEO.js} +5 -5
- package/dist/{chunk-LCRBR7KW.js → chunk-7SVFBJBE.js} +2 -2
- package/dist/{chunk-Y37VJFX2.js → chunk-7XHW5DZA.js} +3 -3
- package/dist/{chunk-3MTZZJKH.js → chunk-AL4HRKSZ.js} +2 -2
- package/dist/{chunk-T3BBNLAT.js → chunk-C37OVJ35.js} +2 -2
- package/dist/{chunk-T3BBNLAT.js.map → chunk-C37OVJ35.js.map} +1 -1
- package/dist/{chunk-3BMTCS4H.js → chunk-CWGBRWP7.js} +3 -3
- package/dist/{chunk-7AXJY4FX.js → chunk-DN4LCWSA.js} +3 -3
- package/dist/{chunk-W5DO426O.js → chunk-DW22KCLN.js} +5 -6
- package/dist/chunk-DW22KCLN.js.map +1 -0
- package/dist/{chunk-BA4TCCOO.js → chunk-FEEO7ET6.js} +3 -3
- package/dist/{chunk-ZPLIXZZ6.js → chunk-FYWQS35G.js} +2 -2
- package/dist/{chunk-W6B24IMO.js → chunk-GLQCSDFS.js} +2 -2
- package/dist/{chunk-GHZAOPGK.js → chunk-GUTAKJIF.js} +4 -4
- package/dist/{chunk-AJYUJ37M.js → chunk-GZHBMMDC.js} +17 -10
- package/dist/chunk-GZHBMMDC.js.map +1 -0
- package/dist/{chunk-D2TIZOMN.js → chunk-IE5PXI6M.js} +3 -3
- package/dist/{chunk-2A6XYSXO.js → chunk-JHE3CYWS.js} +2 -2
- package/dist/{chunk-M534DYAJ.js → chunk-JQPZKWIP.js} +2 -2
- package/dist/{chunk-JTEWU4C6.js → chunk-JTATFPWB.js} +7 -6
- package/dist/chunk-JTATFPWB.js.map +1 -0
- package/dist/{chunk-M43NTWVH.js → chunk-JULE3EU3.js} +5 -5
- package/dist/{chunk-BAWKNF6U.js → chunk-KCXQXKOL.js} +2 -2
- package/dist/{chunk-A7MNH4YI.js → chunk-KN37BXVY.js} +7 -7
- package/dist/{chunk-CZJNYHK7.js → chunk-MAOX3524.js} +2 -2
- package/dist/{chunk-56URKBXQ.js → chunk-NIQ2JSZO.js} +23 -14
- package/dist/chunk-NIQ2JSZO.js.map +1 -0
- package/dist/{chunk-BIRGZEWO.js → chunk-OFOIBV5J.js} +2 -2
- package/dist/{chunk-VBBJGFME.js → chunk-Q2VOXKAQ.js} +4 -4
- package/dist/{chunk-6VT3Z352.js → chunk-Q62Q7CDI.js} +67 -4
- package/dist/chunk-Q62Q7CDI.js.map +1 -0
- package/dist/{chunk-2HQSMZ4N.js → chunk-QDO5JFFV.js} +2 -2
- package/dist/{chunk-JWBS7YDI.js → chunk-QEJ4GH25.js} +3 -3
- package/dist/{chunk-3CCY7M3R.js → chunk-QS3K57OJ.js} +4 -4
- package/dist/{chunk-YJ3EG2D5.js → chunk-RGRNAQG5.js} +3 -3
- package/dist/{chunk-USKTLEPZ.js → chunk-SLGCRXHM.js} +3 -3
- package/dist/{chunk-WIPTWZVH.js → chunk-SVF3WCC7.js} +5 -5
- package/dist/{chunk-66MKBRTA.js → chunk-T62SFCQY.js} +6 -6
- package/dist/{chunk-EXAZ7K25.js → chunk-TXZJESES.js} +2 -2
- package/dist/{chunk-4U3X7LYV.js → chunk-UPUJJOKB.js} +4 -4
- package/dist/{chunk-MIGFQP5N.js → chunk-URGALOZY.js} +2 -2
- package/dist/{chunk-QEZQ7MGH.js → chunk-UVLQRP6O.js} +4 -4
- package/dist/chunk-UVLQRP6O.js.map +1 -0
- package/dist/{chunk-IOYEPB27.js → chunk-Y3GWQBJP.js} +2 -2
- package/dist/{chunk-B6GUSA53.js → chunk-YT5HKJWV.js} +489 -15
- package/dist/chunk-YT5HKJWV.js.map +1 -0
- package/dist/{chunk-HGU4FDRY.js → chunk-Z6PZKXSP.js} +4 -4
- package/dist/{chunk-STM3G7WJ.js → chunk-ZC2MZZR5.js} +4 -4
- package/dist/{cli-XAT673VB.js → cli-33E3B2FK.js} +2 -2
- package/dist/{cli-SOA2E26G.js → cli-7JV4RM66.js} +14 -14
- package/dist/{cli-X6IWTDFK.js → cli-B4DTJ2KC.js} +20 -20
- package/dist/{cli-VQYB3663.js → cli-D4WXCDTS.js} +18 -18
- package/dist/{cli-BUV3DRUH.js → cli-DDLLZHZW.js} +79 -19
- package/dist/cli-DDLLZHZW.js.map +1 -0
- package/dist/{cli-5XKHMRZ5.js → cli-EVACAD7K.js} +16 -16
- package/dist/{cli-LOND37OA.js → cli-LIKI7WPR.js} +36 -36
- package/dist/{cli-O6Y2KVWD.js → cli-MWUFAS2X.js} +9 -9
- package/dist/{cli-7QHJW5GH.js → cli-OKPRTVG6.js} +2 -2
- package/dist/{cli-IKDX2I5X.js → cli-QEPVGLQ3.js} +15 -15
- package/dist/{cli-QTLOAVOY.js → cli-VP6JTPFS.js} +9 -9
- package/dist/cli.js +14 -14
- package/dist/docmeta.js +8 -8
- package/dist/{github-XM36D7ZH.js → github-DV57TW5L.js} +12 -12
- package/dist/{github-IPBOTQBN.js → github-SGX2EARO.js} +14 -14
- package/dist/index.d.ts +130 -25
- package/dist/index.js +38 -38
- package/dist/{json-7WV7KL6H.js → json-5EQCGVCV.js} +4 -2
- package/dist/{json-225TND7K.js → json-SHPUCD64.js} +12 -12
- package/dist/{labels-CTLHIRC4.js → labels-3GCGYYV3.js} +11 -11
- package/dist/{lint-NP3PC3SO.js → lint-RE4DMI6E.js} +12 -12
- package/dist/{list-JJGNKO6S.js → list-F56MEJXR.js} +12 -12
- package/dist/{list-Q457TIMA.js → list-ZR3KY556.js} +12 -12
- package/dist/{page-FJW7J2EU.js → page-G7XSO4FD.js} +11 -11
- package/dist/{prepare-RKJEKHAG.js → prepare-WHMWP7BG.js} +12 -12
- package/dist/{pretty-QFEN2SIA.js → pretty-VTJVXWRK.js} +12 -12
- package/dist/{pretty-ECBO3EVT.js → pretty-YVRRWBWN.js} +21 -15
- package/dist/{reporters-TDQDQHKE.js → reporters-FSXJ42EB.js} +2 -2
- package/dist/{reporters-WGLQKW2Y.js → reporters-G5R4SURQ.js} +4 -4
- package/dist/{reporters-IKKL5RHS.js → reporters-MHPY4HRA.js} +11 -11
- package/dist/{run-BTETGGLW.js → run-FSYOYEPR.js} +13 -13
- package/dist/{sarif-K4SMB563.js → sarif-HBQIDY7T.js} +10 -10
- package/dist/{sarif-ZHFK6PZY.js → sarif-RRUFJZUL.js} +15 -15
- package/dist/{term-2M7APX2A.js → term-ABHGACYE.js} +17 -17
- package/dist/{validate-GBM5STKS.js → validate-DXYUUGUD.js} +5 -5
- package/package.json +1 -1
- package/plugin/manni/.claude-plugin/plugin.json +1 -1
- package/dist/chunk-56URKBXQ.js.map +0 -1
- package/dist/chunk-6VT3Z352.js.map +0 -1
- package/dist/chunk-AJYUJ37M.js.map +0 -1
- package/dist/chunk-B6GUSA53.js.map +0 -1
- package/dist/chunk-JTEWU4C6.js.map +0 -1
- package/dist/chunk-PCE7QHXJ.js.map +0 -1
- package/dist/chunk-QEZQ7MGH.js.map +0 -1
- package/dist/chunk-QF7EIRMU.js.map +0 -1
- package/dist/chunk-W5DO426O.js.map +0 -1
- package/dist/cli-BUV3DRUH.js.map +0 -1
- /package/dist/{batch-TKNIUBLK.js.map → batch-OMDKRGUE.js.map} +0 -0
- /package/dist/{build-6G7PEAG4.js.map → build-YCY5MUHA.js.map} +0 -0
- /package/dist/{calibrate-BDCXDZV5.js.map → calibrate-RN2NJ4FS.js.map} +0 -0
- /package/dist/{capture-NQJLZD66.js.map → capture-2WYROZKA.js.map} +0 -0
- /package/dist/{check-552X5I2J.js.map → check-KRVWHF7E.js.map} +0 -0
- /package/dist/{check-QIZCTAIR.js.map → check-LVUTWAGR.js.map} +0 -0
- /package/dist/{check-5HMDJOFP.js.map → check-MR7IG7IP.js.map} +0 -0
- /package/dist/{check-BSB4FF4L.js.map → check-OIRJ6OBW.js.map} +0 -0
- /package/dist/{chunk-7PENJOI6.js.map → chunk-3CSEHHKB.js.map} +0 -0
- /package/dist/{chunk-Y36PNW6J.js.map → chunk-3EJVJDMX.js.map} +0 -0
- /package/dist/{chunk-V6OCE4ND.js.map → chunk-3WQMMLIO.js.map} +0 -0
- /package/dist/{chunk-36FJWJSK.js.map → chunk-476DMDJ5.js.map} +0 -0
- /package/dist/{chunk-7KOWE4F4.js.map → chunk-4MYW2D2U.js.map} +0 -0
- /package/dist/{chunk-6XFSZCLT.js.map → chunk-525KMBZS.js.map} +0 -0
- /package/dist/{chunk-ZRQUQS7P.js.map → chunk-57DHX65T.js.map} +0 -0
- /package/dist/{chunk-7WVWGULD.js.map → chunk-7EKXSSEO.js.map} +0 -0
- /package/dist/{chunk-LCRBR7KW.js.map → chunk-7SVFBJBE.js.map} +0 -0
- /package/dist/{chunk-Y37VJFX2.js.map → chunk-7XHW5DZA.js.map} +0 -0
- /package/dist/{chunk-3MTZZJKH.js.map → chunk-AL4HRKSZ.js.map} +0 -0
- /package/dist/{chunk-3BMTCS4H.js.map → chunk-CWGBRWP7.js.map} +0 -0
- /package/dist/{chunk-7AXJY4FX.js.map → chunk-DN4LCWSA.js.map} +0 -0
- /package/dist/{chunk-BA4TCCOO.js.map → chunk-FEEO7ET6.js.map} +0 -0
- /package/dist/{chunk-ZPLIXZZ6.js.map → chunk-FYWQS35G.js.map} +0 -0
- /package/dist/{chunk-W6B24IMO.js.map → chunk-GLQCSDFS.js.map} +0 -0
- /package/dist/{chunk-GHZAOPGK.js.map → chunk-GUTAKJIF.js.map} +0 -0
- /package/dist/{chunk-D2TIZOMN.js.map → chunk-IE5PXI6M.js.map} +0 -0
- /package/dist/{chunk-2A6XYSXO.js.map → chunk-JHE3CYWS.js.map} +0 -0
- /package/dist/{chunk-M534DYAJ.js.map → chunk-JQPZKWIP.js.map} +0 -0
- /package/dist/{chunk-M43NTWVH.js.map → chunk-JULE3EU3.js.map} +0 -0
- /package/dist/{chunk-BAWKNF6U.js.map → chunk-KCXQXKOL.js.map} +0 -0
- /package/dist/{chunk-A7MNH4YI.js.map → chunk-KN37BXVY.js.map} +0 -0
- /package/dist/{chunk-CZJNYHK7.js.map → chunk-MAOX3524.js.map} +0 -0
- /package/dist/{chunk-BIRGZEWO.js.map → chunk-OFOIBV5J.js.map} +0 -0
- /package/dist/{chunk-VBBJGFME.js.map → chunk-Q2VOXKAQ.js.map} +0 -0
- /package/dist/{chunk-2HQSMZ4N.js.map → chunk-QDO5JFFV.js.map} +0 -0
- /package/dist/{chunk-JWBS7YDI.js.map → chunk-QEJ4GH25.js.map} +0 -0
- /package/dist/{chunk-3CCY7M3R.js.map → chunk-QS3K57OJ.js.map} +0 -0
- /package/dist/{chunk-YJ3EG2D5.js.map → chunk-RGRNAQG5.js.map} +0 -0
- /package/dist/{chunk-USKTLEPZ.js.map → chunk-SLGCRXHM.js.map} +0 -0
- /package/dist/{chunk-WIPTWZVH.js.map → chunk-SVF3WCC7.js.map} +0 -0
- /package/dist/{chunk-66MKBRTA.js.map → chunk-T62SFCQY.js.map} +0 -0
- /package/dist/{chunk-EXAZ7K25.js.map → chunk-TXZJESES.js.map} +0 -0
- /package/dist/{chunk-4U3X7LYV.js.map → chunk-UPUJJOKB.js.map} +0 -0
- /package/dist/{chunk-MIGFQP5N.js.map → chunk-URGALOZY.js.map} +0 -0
- /package/dist/{chunk-IOYEPB27.js.map → chunk-Y3GWQBJP.js.map} +0 -0
- /package/dist/{chunk-HGU4FDRY.js.map → chunk-Z6PZKXSP.js.map} +0 -0
- /package/dist/{chunk-STM3G7WJ.js.map → chunk-ZC2MZZR5.js.map} +0 -0
- /package/dist/{cli-XAT673VB.js.map → cli-33E3B2FK.js.map} +0 -0
- /package/dist/{cli-SOA2E26G.js.map → cli-7JV4RM66.js.map} +0 -0
- /package/dist/{cli-X6IWTDFK.js.map → cli-B4DTJ2KC.js.map} +0 -0
- /package/dist/{cli-VQYB3663.js.map → cli-D4WXCDTS.js.map} +0 -0
- /package/dist/{cli-5XKHMRZ5.js.map → cli-EVACAD7K.js.map} +0 -0
- /package/dist/{cli-LOND37OA.js.map → cli-LIKI7WPR.js.map} +0 -0
- /package/dist/{cli-O6Y2KVWD.js.map → cli-MWUFAS2X.js.map} +0 -0
- /package/dist/{cli-7QHJW5GH.js.map → cli-OKPRTVG6.js.map} +0 -0
- /package/dist/{cli-IKDX2I5X.js.map → cli-QEPVGLQ3.js.map} +0 -0
- /package/dist/{cli-QTLOAVOY.js.map → cli-VP6JTPFS.js.map} +0 -0
- /package/dist/{github-IPBOTQBN.js.map → github-DV57TW5L.js.map} +0 -0
- /package/dist/{github-XM36D7ZH.js.map → github-SGX2EARO.js.map} +0 -0
- /package/dist/{json-225TND7K.js.map → json-5EQCGVCV.js.map} +0 -0
- /package/dist/{json-7WV7KL6H.js.map → json-SHPUCD64.js.map} +0 -0
- /package/dist/{labels-CTLHIRC4.js.map → labels-3GCGYYV3.js.map} +0 -0
- /package/dist/{lint-NP3PC3SO.js.map → lint-RE4DMI6E.js.map} +0 -0
- /package/dist/{list-JJGNKO6S.js.map → list-F56MEJXR.js.map} +0 -0
- /package/dist/{list-Q457TIMA.js.map → list-ZR3KY556.js.map} +0 -0
- /package/dist/{page-FJW7J2EU.js.map → page-G7XSO4FD.js.map} +0 -0
- /package/dist/{prepare-RKJEKHAG.js.map → prepare-WHMWP7BG.js.map} +0 -0
- /package/dist/{pretty-ECBO3EVT.js.map → pretty-VTJVXWRK.js.map} +0 -0
- /package/dist/{pretty-QFEN2SIA.js.map → pretty-YVRRWBWN.js.map} +0 -0
- /package/dist/{reporters-IKKL5RHS.js.map → reporters-FSXJ42EB.js.map} +0 -0
- /package/dist/{reporters-TDQDQHKE.js.map → reporters-G5R4SURQ.js.map} +0 -0
- /package/dist/{reporters-WGLQKW2Y.js.map → reporters-MHPY4HRA.js.map} +0 -0
- /package/dist/{run-BTETGGLW.js.map → run-FSYOYEPR.js.map} +0 -0
- /package/dist/{sarif-K4SMB563.js.map → sarif-HBQIDY7T.js.map} +0 -0
- /package/dist/{sarif-ZHFK6PZY.js.map → sarif-RRUFJZUL.js.map} +0 -0
- /package/dist/{term-2M7APX2A.js.map → term-ABHGACYE.js.map} +0 -0
- /package/dist/{validate-GBM5STKS.js.map → validate-DXYUUGUD.js.map} +0 -0
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
toValidationResult,
|
|
15
15
|
unitText,
|
|
16
16
|
withRemedy
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-GZHBMMDC.js";
|
|
18
18
|
import {
|
|
19
19
|
ANY_FENCE,
|
|
20
20
|
CITE_RULES,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
sliceLines,
|
|
35
35
|
sourceRange,
|
|
36
36
|
spellSource
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-UVLQRP6O.js";
|
|
38
38
|
import {
|
|
39
39
|
MAX_RANGE_LINES,
|
|
40
40
|
MOVE_BUDGET_BYTES,
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
spellLines,
|
|
58
58
|
splitLines,
|
|
59
59
|
toBodyLines
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-476DMDJ5.js";
|
|
61
61
|
import {
|
|
62
62
|
STDIN_LABEL,
|
|
63
63
|
STDIN_TOKEN,
|
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
resolveTargetSet,
|
|
72
72
|
settleBaseline,
|
|
73
73
|
supportedExtensions
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-OFOIBV5J.js";
|
|
75
75
|
import {
|
|
76
76
|
SEVERITIES
|
|
77
77
|
} from "./chunk-77AINBYM.js";
|
|
@@ -95,6 +95,301 @@ import { existsSync as existsSync2 } from "node:fs";
|
|
|
95
95
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
96
96
|
import { resolve as resolve3 } from "node:path";
|
|
97
97
|
|
|
98
|
+
// src/cite/core/history.ts
|
|
99
|
+
var MAX_PAGE_COMMITS = 256;
|
|
100
|
+
function stripMarkers(lines, format) {
|
|
101
|
+
return lines.filter((line) => !isMarkerLine(line, format));
|
|
102
|
+
}
|
|
103
|
+
function claimWords(lines, format) {
|
|
104
|
+
return stripMarkers(lines, format).join(" ").replace(/\s+/g, " ").trim();
|
|
105
|
+
}
|
|
106
|
+
function sentencesOf(text) {
|
|
107
|
+
return text.split(/(?<=[.!?])\s+/).map((sentence) => sentence.replace(/\s+/g, " ").trim().toLowerCase()).filter((sentence) => sentence !== "");
|
|
108
|
+
}
|
|
109
|
+
function sharesSentence(a, b) {
|
|
110
|
+
const left = new Set(sentencesOf(a));
|
|
111
|
+
return sentencesOf(b).some((sentence) => left.has(sentence));
|
|
112
|
+
}
|
|
113
|
+
function wordSet(text) {
|
|
114
|
+
return new Set(
|
|
115
|
+
text.toLowerCase().split(/\s+/).filter((word) => word !== "")
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
function wordShare(was, now) {
|
|
119
|
+
const left = wordSet(was);
|
|
120
|
+
if (left.size === 0) return 1;
|
|
121
|
+
const right = wordSet(now);
|
|
122
|
+
let held = 0;
|
|
123
|
+
for (const word of left) if (right.has(word)) held++;
|
|
124
|
+
return held / left.size;
|
|
125
|
+
}
|
|
126
|
+
function holdsWords(outer, inner) {
|
|
127
|
+
if (inner === "") return true;
|
|
128
|
+
if (outer === inner) return true;
|
|
129
|
+
if (outer.startsWith(`${inner} `)) return true;
|
|
130
|
+
if (outer.endsWith(` ${inner}`)) return true;
|
|
131
|
+
return outer.includes(` ${inner} `);
|
|
132
|
+
}
|
|
133
|
+
function runsHolding(lines, format, bodyLine, inner) {
|
|
134
|
+
if (inner === "") return [];
|
|
135
|
+
let text = "";
|
|
136
|
+
const at = [];
|
|
137
|
+
for (let n = Math.max(bodyLine, 1); n <= lines.length; n++) {
|
|
138
|
+
const line = lines[n - 1] ?? "";
|
|
139
|
+
if (isMarkerLine(line, format)) continue;
|
|
140
|
+
const words = line.replace(/\s+/g, " ").trim();
|
|
141
|
+
if (words === "") continue;
|
|
142
|
+
if (text !== "") {
|
|
143
|
+
text += " ";
|
|
144
|
+
at.push(n);
|
|
145
|
+
}
|
|
146
|
+
for (let i = 0; i < words.length; i++) at.push(n);
|
|
147
|
+
text += words;
|
|
148
|
+
}
|
|
149
|
+
const out = [];
|
|
150
|
+
let from = 0;
|
|
151
|
+
for (; ; ) {
|
|
152
|
+
const found = text.indexOf(inner, from);
|
|
153
|
+
if (found === -1) break;
|
|
154
|
+
from = found + 1;
|
|
155
|
+
const before = found === 0 ? " " : text[found - 1];
|
|
156
|
+
const afterAt = found + inner.length;
|
|
157
|
+
const after = afterAt === text.length ? " " : text[afterAt];
|
|
158
|
+
if (before !== " " || after !== " ") continue;
|
|
159
|
+
const start = at[found];
|
|
160
|
+
const end = at[afterAt - 1];
|
|
161
|
+
if (start === void 0 || end === void 0) continue;
|
|
162
|
+
if (!out.some((span) => span.start === start && span.end === end)) out.push({ start, end });
|
|
163
|
+
}
|
|
164
|
+
return out.filter(
|
|
165
|
+
(span) => !out.some(
|
|
166
|
+
(other) => (other.start !== span.start || other.end !== span.end) && other.start >= span.start && other.end <= span.end
|
|
167
|
+
)
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
function bounds(line) {
|
|
171
|
+
return line === void 0 || line.trim() === "" || ANY_FENCE.test(line);
|
|
172
|
+
}
|
|
173
|
+
function pinOf(lines, span) {
|
|
174
|
+
if (span.start < 1 || span.end > lines.length || span.end < span.start) return void 0;
|
|
175
|
+
return hashLines(lines.slice(span.start - 1, span.end).join("\n"));
|
|
176
|
+
}
|
|
177
|
+
function readThen(input, text) {
|
|
178
|
+
const then = readPage(input.page.file, text, { format: input.page.format });
|
|
179
|
+
const lines = splitLines(then.content);
|
|
180
|
+
if (input.entry.citation.claim?.lines !== void 0) return { page: then, lines };
|
|
181
|
+
const id = input.entry.citation.id;
|
|
182
|
+
if (id === void 0) return void 0;
|
|
183
|
+
const marker = then.statements.find(
|
|
184
|
+
(statement) => statement.payload.kind === "ref" && statement.payload.ids.includes(id)
|
|
185
|
+
);
|
|
186
|
+
if (marker === void 0) return void 0;
|
|
187
|
+
return { page: then, lines, marker };
|
|
188
|
+
}
|
|
189
|
+
function anchorHeldAt(input, then) {
|
|
190
|
+
const pin = input.entry.citation.claim?.integrity;
|
|
191
|
+
if (pin === void 0) return { kind: "absent" };
|
|
192
|
+
const was = {
|
|
193
|
+
citation: input.entry.citation,
|
|
194
|
+
origin: input.entry.origin,
|
|
195
|
+
...then.marker === void 0 ? {} : { marker: then.marker }
|
|
196
|
+
};
|
|
197
|
+
const split = then.marker === void 0 ? void 0 : misplacedMarkerAt(then.page, then.lines, then.marker.line, was);
|
|
198
|
+
const end = claimEnd(then.page, was, then.lines, split);
|
|
199
|
+
if (end === null || end.status !== "current" && end.status !== "moved") {
|
|
200
|
+
return { kind: "absent" };
|
|
201
|
+
}
|
|
202
|
+
for (const spec of [end.fileLines, end.newFileLines]) {
|
|
203
|
+
const span = spec === void 0 ? void 0 : parseLines(spec);
|
|
204
|
+
if (span !== void 0 && pinOf(then.lines, span) === pin) {
|
|
205
|
+
return { kind: "found", span, lines: then.lines.slice(span.start - 1, span.end) };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (split !== void 0) {
|
|
209
|
+
const text = unitText(then.lines, split);
|
|
210
|
+
if (hashLines(text.join("\n")) === pin) {
|
|
211
|
+
return { kind: "found", span: movedUnit(split), lines: text };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { kind: "absent" };
|
|
215
|
+
}
|
|
216
|
+
function windowHeldAt(input, then) {
|
|
217
|
+
const pin = input.entry.citation.claim?.integrity;
|
|
218
|
+
const marker = then.marker;
|
|
219
|
+
if (pin === void 0 || marker === void 0) return { kind: "absent" };
|
|
220
|
+
if (input.entry.citation.quote === true) return { kind: "absent" };
|
|
221
|
+
const lines = then.lines;
|
|
222
|
+
let stop = marker.line;
|
|
223
|
+
for (let n = marker.line + 1; n <= lines.length; n++) {
|
|
224
|
+
if (bounds(lines[n - 1])) break;
|
|
225
|
+
stop = n;
|
|
226
|
+
}
|
|
227
|
+
const starts = [marker.line];
|
|
228
|
+
for (let n = marker.line + 1; n <= stop; n++) {
|
|
229
|
+
const line = lines[n - 1] ?? "";
|
|
230
|
+
if (line.trim() === "" || isMarkerLine(line, then.page.format)) continue;
|
|
231
|
+
starts.push(n);
|
|
232
|
+
}
|
|
233
|
+
for (const start of starts) {
|
|
234
|
+
for (let end = start; end <= stop; end++) {
|
|
235
|
+
if (pinOf(lines, { start, end }) === pin) {
|
|
236
|
+
return { kind: "found", span: { start, end }, lines: lines.slice(start - 1, end) };
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return { kind: "absent" };
|
|
241
|
+
}
|
|
242
|
+
async function stillWritten(input, commit, pageText) {
|
|
243
|
+
const pin = input.entry.citation.claim?.integrity;
|
|
244
|
+
if (pin === void 0) return { stop: true, born: true };
|
|
245
|
+
const manifest = input.manifest;
|
|
246
|
+
if (manifest !== void 0) {
|
|
247
|
+
const shown = await input.git.showFile(commit, manifest);
|
|
248
|
+
const held2 = "text" in shown && shown.text.includes(pin);
|
|
249
|
+
return { stop: !held2, born: !held2 };
|
|
250
|
+
}
|
|
251
|
+
const held = pageText.includes(pin);
|
|
252
|
+
return { stop: false, born: !held };
|
|
253
|
+
}
|
|
254
|
+
async function claimHistory(input) {
|
|
255
|
+
const { git, path } = input;
|
|
256
|
+
if (git.pageCommits === void 0) return { kind: "none" };
|
|
257
|
+
if (!await git.available()) return { kind: "none" };
|
|
258
|
+
const cap = input.cap ?? MAX_PAGE_COMMITS;
|
|
259
|
+
const history = await git.pageCommits(path, cap);
|
|
260
|
+
const { commits } = history;
|
|
261
|
+
if (commits.length === 0) return { kind: "none" };
|
|
262
|
+
const format = input.page.format;
|
|
263
|
+
const baselineAt = (index, then, found) => {
|
|
264
|
+
if (found.kind !== "found") return { kind: "none" };
|
|
265
|
+
const commit = commits[index];
|
|
266
|
+
if (commit === void 0) return { kind: "none" };
|
|
267
|
+
return {
|
|
268
|
+
kind: "baseline",
|
|
269
|
+
commit: commit.sha,
|
|
270
|
+
commitsSince: commits.slice(0, index).map((c) => c.subject),
|
|
271
|
+
words: claimWords(found.lines, format),
|
|
272
|
+
pageWords: claimWords(then.lines.slice(then.page.bodyLine - 1), format),
|
|
273
|
+
lines: found.lines,
|
|
274
|
+
at: spellLines(found.span)
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
const examined = [];
|
|
278
|
+
let ended = "cap";
|
|
279
|
+
let born = false;
|
|
280
|
+
for (let i = 0; i < commits.length; i++) {
|
|
281
|
+
const commit = commits[i];
|
|
282
|
+
if (commit === void 0) continue;
|
|
283
|
+
const shown = await git.showFile(commit.sha, path);
|
|
284
|
+
if (!("text" in shown)) {
|
|
285
|
+
ended = shown.missing === "commit" ? "unavailable" : "birth";
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
const then = readThen(input, shown.text);
|
|
289
|
+
if (then === void 0) {
|
|
290
|
+
ended = "birth";
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
examined.push(then);
|
|
294
|
+
const found = anchorHeldAt(input, then);
|
|
295
|
+
if (found.kind === "found") return baselineAt(i, then, found);
|
|
296
|
+
const written = await stillWritten(input, commit.sha, shown.text);
|
|
297
|
+
if (written.born) born = true;
|
|
298
|
+
if (written.stop) {
|
|
299
|
+
ended = "birth";
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
for (const [i, then] of examined.entries()) {
|
|
304
|
+
const found = windowHeldAt(input, then);
|
|
305
|
+
if (found.kind === "found") return baselineAt(i, then, found);
|
|
306
|
+
}
|
|
307
|
+
if (ended === "birth" || born) return { kind: "none" };
|
|
308
|
+
if (ended === "unavailable") return { kind: "unavailable" };
|
|
309
|
+
return history.truncated || history.shallow ? { kind: "unavailable" } : { kind: "none" };
|
|
310
|
+
}
|
|
311
|
+
function claimDiff(input) {
|
|
312
|
+
const a = input.was.lines;
|
|
313
|
+
const b = input.now.lines;
|
|
314
|
+
let head = 0;
|
|
315
|
+
while (head < a.length && head < b.length && a[head] === b[head]) head++;
|
|
316
|
+
let tail = 0;
|
|
317
|
+
while (tail < a.length - head && tail < b.length - head && a[a.length - 1 - tail] === b[b.length - 1 - tail]) {
|
|
318
|
+
tail++;
|
|
319
|
+
}
|
|
320
|
+
const out = [
|
|
321
|
+
`--- ${input.file}@${shortCommit(input.commit)}:${input.was.at}`,
|
|
322
|
+
`+++ ${input.file}:${input.now.at}`
|
|
323
|
+
];
|
|
324
|
+
for (const line of a.slice(0, head)) out.push(` ${line}`);
|
|
325
|
+
for (const line of a.slice(head, a.length - tail)) out.push(`-${line}`);
|
|
326
|
+
for (const line of b.slice(head, b.length - tail)) out.push(`+${line}`);
|
|
327
|
+
for (const line of a.slice(a.length - tail)) out.push(` ${line}`);
|
|
328
|
+
return out.join("\n");
|
|
329
|
+
}
|
|
330
|
+
function refineClaim(input) {
|
|
331
|
+
const { claim, history, entry, page, lines } = input;
|
|
332
|
+
if (history.kind === "unavailable") return { ...claim, historyAvailable: false };
|
|
333
|
+
if (history.kind === "none") return claim;
|
|
334
|
+
const format = page.format;
|
|
335
|
+
const base = {
|
|
336
|
+
...claim,
|
|
337
|
+
commitSha: history.commit,
|
|
338
|
+
historyAvailable: true,
|
|
339
|
+
commitsSince: history.commitsSince,
|
|
340
|
+
baselineText: history.lines
|
|
341
|
+
};
|
|
342
|
+
const withDiff = (end, now2) => {
|
|
343
|
+
const diff = claimDiff({
|
|
344
|
+
file: page.file,
|
|
345
|
+
commit: history.commit,
|
|
346
|
+
was: { at: history.at, lines: history.lines },
|
|
347
|
+
now: now2
|
|
348
|
+
});
|
|
349
|
+
return { ...end, diff };
|
|
350
|
+
};
|
|
351
|
+
if (entry.citation.quote === true) {
|
|
352
|
+
const now2 = claim.text ?? [];
|
|
353
|
+
const same = stripMarkers(now2, format).join("\n") === stripMarkers(history.lines, format).join("\n");
|
|
354
|
+
const at = claim.fileLines ?? history.at;
|
|
355
|
+
return withDiff(same ? { ...base, status: "reanchored" } : base, { at, lines: now2 });
|
|
356
|
+
}
|
|
357
|
+
if (entry.citation.claim?.lines === void 0) {
|
|
358
|
+
const now2 = claim.text ?? [];
|
|
359
|
+
const w12 = claimWords(now2, format);
|
|
360
|
+
const at = claim.fileLines ?? history.at;
|
|
361
|
+
const held = holdsWords(w12, history.words) && holdsWords(history.pageWords, w12);
|
|
362
|
+
return withDiff(held ? { ...base, status: "reanchored" } : base, { at, lines: now2 });
|
|
363
|
+
}
|
|
364
|
+
const runs = runsHolding(lines, format, page.bodyLine, history.words);
|
|
365
|
+
const [only] = runs;
|
|
366
|
+
if (runs.length > 1) {
|
|
367
|
+
return {
|
|
368
|
+
...claim,
|
|
369
|
+
status: "moved-ambiguous",
|
|
370
|
+
candidates: runs.map((span) => spellLines(toBodyLines(span, page.bodyLine))),
|
|
371
|
+
candidateFileLines: runs.map(spellLines)
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
if (only === void 0) {
|
|
375
|
+
return withDiff(base, { at: claim.fileLines ?? history.at, lines: claim.text ?? [] });
|
|
376
|
+
}
|
|
377
|
+
const now = lines.slice(only.start - 1, only.end);
|
|
378
|
+
const w1 = claimWords(now, format);
|
|
379
|
+
if (!holdsWords(history.pageWords, w1)) {
|
|
380
|
+
return withDiff(base, { at: claim.fileLines ?? history.at, lines: claim.text ?? [] });
|
|
381
|
+
}
|
|
382
|
+
return withDiff(
|
|
383
|
+
{
|
|
384
|
+
...base,
|
|
385
|
+
status: "reanchored",
|
|
386
|
+
newLines: spellLines(toBodyLines(only, page.bodyLine)),
|
|
387
|
+
newFileLines: spellLines(only)
|
|
388
|
+
},
|
|
389
|
+
{ at: spellLines(only), lines: now }
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
98
393
|
// src/cite/core/sources.ts
|
|
99
394
|
import fg from "fast-glob";
|
|
100
395
|
import { lstat, readFile, realpath } from "node:fs/promises";
|
|
@@ -177,13 +472,13 @@ async function readSource(root, index, range, key, cache) {
|
|
|
177
472
|
const resolvedPath = resolved.path;
|
|
178
473
|
if (!index.has(resolvedPath)) return { kind: "missing", reason: "untracked" };
|
|
179
474
|
if (cache === void 0) {
|
|
180
|
-
const text = await
|
|
475
|
+
const text = await readIndexed(root, index, resolvedPath);
|
|
181
476
|
return text === void 0 ? { kind: "missing", reason: "unreadable" } : { kind: "ok", resolvedPath, text };
|
|
182
477
|
}
|
|
183
478
|
const slot = JSON.stringify([root, resolvedPath]);
|
|
184
479
|
let read = cache.get(slot);
|
|
185
480
|
if (read === void 0) {
|
|
186
|
-
read =
|
|
481
|
+
read = readIndexed(root, index, resolvedPath).then(
|
|
187
482
|
(text) => text === void 0 ? void 0 : { text, lines: splitLines(text) }
|
|
188
483
|
);
|
|
189
484
|
cache.set(slot, read);
|
|
@@ -191,6 +486,9 @@ async function readSource(root, index, range, key, cache) {
|
|
|
191
486
|
const file = await read;
|
|
192
487
|
return file === void 0 ? { kind: "missing", reason: "unreadable" } : { kind: "ok", resolvedPath, text: file.text, lines: file.lines };
|
|
193
488
|
}
|
|
489
|
+
function readIndexed(root, index, path) {
|
|
490
|
+
return index.read === void 0 ? readTracked(root, path) : index.read(path);
|
|
491
|
+
}
|
|
194
492
|
async function readTracked(root, path) {
|
|
195
493
|
try {
|
|
196
494
|
return await readFile(join(root, path), "utf8");
|
|
@@ -227,6 +525,58 @@ async function historyOf(git, commit, path, range, pin, key, budget, counter) {
|
|
|
227
525
|
}
|
|
228
526
|
return found.truncated ? { kind: "unknown" } : { kind: "never-true" };
|
|
229
527
|
}
|
|
528
|
+
async function sourceBaseline(git, recorded, path, range, pin, key, budget, counter) {
|
|
529
|
+
const at = (commit) => historyOf(git, commit, path, range, pin, key, budget, counter);
|
|
530
|
+
if (git.pageCommits === void 0) {
|
|
531
|
+
if (recorded === void 0) return { history: { kind: "none" } };
|
|
532
|
+
const history = await at(recorded);
|
|
533
|
+
return history.kind === "original" ? { history, commit: recorded } : { history };
|
|
534
|
+
}
|
|
535
|
+
if (recorded !== void 0 && await inHistory(git, recorded)) {
|
|
536
|
+
const history = await at(recorded);
|
|
537
|
+
if (history.kind === "original") return { history, commit: recorded };
|
|
538
|
+
}
|
|
539
|
+
const { commits, shallow, truncated } = await git.pageCommits(path, MAX_PAGE_COMMITS);
|
|
540
|
+
let unknown = false;
|
|
541
|
+
for (const [i, commit] of commits.entries()) {
|
|
542
|
+
const history = await at(commit.sha);
|
|
543
|
+
if (history.kind === "original") {
|
|
544
|
+
return {
|
|
545
|
+
history,
|
|
546
|
+
commit: commit.sha,
|
|
547
|
+
commitsSince: commits.slice(0, i).map((c) => c.subject)
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
if (history.kind === "unavailable") return { history };
|
|
551
|
+
if (history.kind === "unknown") unknown = true;
|
|
552
|
+
}
|
|
553
|
+
if (shallow || truncated) return { history: { kind: "unavailable" } };
|
|
554
|
+
return { history: unknown ? { kind: "unknown" } : { kind: "never-true" } };
|
|
555
|
+
}
|
|
556
|
+
async function inHistory(git, commit) {
|
|
557
|
+
if (git.isAncestor === void 0) return true;
|
|
558
|
+
const head = await git.head();
|
|
559
|
+
if (head === null) return true;
|
|
560
|
+
return git.isAncestor(commit, head);
|
|
561
|
+
}
|
|
562
|
+
async function arrivalOf(git, path, range, pin, key) {
|
|
563
|
+
if (git.pageCommits === void 0) return void 0;
|
|
564
|
+
const { commits } = await git.pageCommits(path, MAX_PAGE_COMMITS);
|
|
565
|
+
let arrived;
|
|
566
|
+
for (const commit of commits) {
|
|
567
|
+
const shown = await git.showFile(commit.sha, path);
|
|
568
|
+
if (!("text" in shown) || !holdsAt(shown.text, range, pin, key)) break;
|
|
569
|
+
arrived = commit.sha;
|
|
570
|
+
}
|
|
571
|
+
return arrived;
|
|
572
|
+
}
|
|
573
|
+
function holdsAt(text, range, pin, key) {
|
|
574
|
+
try {
|
|
575
|
+
return hashLines(sliceLines(splitLines(text), range), key) === pin;
|
|
576
|
+
} catch {
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
230
580
|
async function followAcross(ask, counter) {
|
|
231
581
|
const hits = [];
|
|
232
582
|
const length = ask.original.length;
|
|
@@ -235,7 +585,7 @@ async function followAcross(ask, counter) {
|
|
|
235
585
|
(path) => path !== ask.own && ask.index.has(path)
|
|
236
586
|
);
|
|
237
587
|
for (const path of candidates2) {
|
|
238
|
-
const text = await
|
|
588
|
+
const text = await readIndexed(ask.root, ask.index, path);
|
|
239
589
|
if (text === void 0) continue;
|
|
240
590
|
const bytes = Buffer.byteLength(text, "utf8");
|
|
241
591
|
if (bytes > counter.left) return { hits, truncated: true };
|
|
@@ -297,11 +647,14 @@ async function classifyCitation(entry, opts) {
|
|
|
297
647
|
}
|
|
298
648
|
}
|
|
299
649
|
const counter = { left: opts.budget ?? MOVE_BUDGET_BYTES };
|
|
300
|
-
let
|
|
301
|
-
if (
|
|
302
|
-
|
|
650
|
+
let derived = { history: { kind: "none" } };
|
|
651
|
+
if (await opts.git.available()) {
|
|
652
|
+
derived = await sourceBaseline(opts.git, commit, path, range, pin, key, opts.budget, counter);
|
|
303
653
|
}
|
|
654
|
+
const history = derived.history;
|
|
655
|
+
const baseline = derived.commit;
|
|
304
656
|
const original = history.kind === "original" ? history.lines : void 0;
|
|
657
|
+
if (baseline !== void 0) result.baselineSha = baseline;
|
|
305
658
|
const spellAt = (at, start, end) => {
|
|
306
659
|
const written = range.encrypted && opts.key !== void 0 ? encryptSourcePath(at, opts.key) : at;
|
|
307
660
|
return formatSrc({ path: written, encrypted: range.encrypted, ...start === void 0 ? {} : { start, end } });
|
|
@@ -328,9 +681,9 @@ async function classifyCitation(entry, opts) {
|
|
|
328
681
|
return result;
|
|
329
682
|
}
|
|
330
683
|
}
|
|
331
|
-
if (
|
|
684
|
+
if (baseline !== void 0 && original !== void 0) {
|
|
332
685
|
const across = await followAcross(
|
|
333
|
-
{ git: opts.git, root: opts.root, index: opts.index, commit, own: path, pin, key, original },
|
|
686
|
+
{ git: opts.git, root: opts.root, index: opts.index, commit: baseline, own: path, pin, key, original },
|
|
334
687
|
counter
|
|
335
688
|
);
|
|
336
689
|
if (across.truncated) {
|
|
@@ -364,10 +717,10 @@ async function classifyCitation(entry, opts) {
|
|
|
364
717
|
result.status = "changed";
|
|
365
718
|
if (history.kind === "unavailable") result.historyAvailable = false;
|
|
366
719
|
if (history.kind === "unknown") result.truncatedSearch = true;
|
|
367
|
-
if (original !== void 0 &&
|
|
720
|
+
if (original !== void 0 && baseline !== void 0) {
|
|
368
721
|
result.historyAvailable = true;
|
|
369
|
-
result.commitsSince = await opts.git.subjectsSince(
|
|
370
|
-
result.diff = await opts.git.diffSince(
|
|
722
|
+
result.commitsSince = derived.commitsSince ?? await opts.git.subjectsSince(baseline, path);
|
|
723
|
+
result.diff = await opts.git.diffSince(baseline, path);
|
|
371
724
|
const span = range.start === void 0 ? void 0 : spanOf(lines, original);
|
|
372
725
|
if (span !== void 0) result.newLines = String(lineSpec(span));
|
|
373
726
|
}
|
|
@@ -375,16 +728,16 @@ async function classifyCitation(entry, opts) {
|
|
|
375
728
|
}
|
|
376
729
|
|
|
377
730
|
// src/cite/core/git.ts
|
|
378
|
-
import { execFile } from "node:child_process";
|
|
731
|
+
import { execFile, spawn } from "node:child_process";
|
|
379
732
|
var MAX_BUFFER = 32 * 1024 * 1024;
|
|
380
733
|
var NO_COMMIT = /invalid object name|bad revision|unknown revision|bad object/i;
|
|
381
734
|
var NO_PATH = /does not exist in|exists on disk, but not in|path .* does not exist/i;
|
|
382
|
-
function run(root, args) {
|
|
735
|
+
function run(root, args, maxBuffer = MAX_BUFFER) {
|
|
383
736
|
return new Promise((resolve4) => {
|
|
384
737
|
execFile(
|
|
385
738
|
"git",
|
|
386
739
|
["-c", "core.quotepath=false", ...args],
|
|
387
|
-
{ cwd: root, windowsHide: true, maxBuffer
|
|
740
|
+
{ cwd: root, windowsHide: true, maxBuffer, encoding: "utf8" },
|
|
388
741
|
(error, stdout, stderr) => {
|
|
389
742
|
if (error) {
|
|
390
743
|
const failure = { ok: false, stderr, message: error.message };
|
|
@@ -395,7 +748,7 @@ function run(root, args) {
|
|
|
395
748
|
);
|
|
396
749
|
});
|
|
397
750
|
}
|
|
398
|
-
function gitClient(root) {
|
|
751
|
+
function gitClient(root, rev = "HEAD") {
|
|
399
752
|
const memo = /* @__PURE__ */ new Map();
|
|
400
753
|
const once = (key, compute) => {
|
|
401
754
|
const held = memo.get(key);
|
|
@@ -433,7 +786,7 @@ function gitClient(root) {
|
|
|
433
786
|
}),
|
|
434
787
|
head: () => once("head", async () => {
|
|
435
788
|
if (!await available()) return null;
|
|
436
|
-
const out = await run(root, ["rev-parse", "
|
|
789
|
+
const out = await run(root, ["rev-parse", "--verify", "--quiet", "--end-of-options", `${rev}^{commit}`]);
|
|
437
790
|
return out.ok ? out.stdout.trim() : null;
|
|
438
791
|
}),
|
|
439
792
|
lsFiles: () => once("ls-files", async () => {
|
|
@@ -452,21 +805,23 @@ function gitClient(root) {
|
|
|
452
805
|
throw failed("show", out);
|
|
453
806
|
}),
|
|
454
807
|
subjectsSince: (commit, path) => once(`log\0${commit}\0${path}`, async () => {
|
|
455
|
-
const out = await run(root, ["log", "--format=%s", "--end-of-options", `${commit}
|
|
808
|
+
const out = await run(root, ["log", "--format=%s", "--end-of-options", `${commit}..${rev}`, "--", path]);
|
|
456
809
|
if (!out.ok) throw failed("log", out);
|
|
457
810
|
return out.stdout.split(/\r?\n/).filter((line) => line !== "");
|
|
458
811
|
}),
|
|
459
|
-
// `HEAD`
|
|
460
|
-
// to the working tree, and this list is committed
|
|
461
|
-
// that is merely saved is never followed into a
|
|
812
|
+
// The revision is written out, `HEAD` for a check: with no second revision
|
|
813
|
+
// git compares the commit to the working tree, and this list is committed
|
|
814
|
+
// changes only, so a move that is merely saved is never followed into a
|
|
815
|
+
// page (0055 stress test 8).
|
|
462
816
|
changedSince: (commit) => once(`changed\0${commit}`, async () => {
|
|
463
817
|
if (!await available()) return [];
|
|
464
|
-
const out = await run(root, ["diff", "--name-only", "--end-of-options", commit,
|
|
818
|
+
const out = await run(root, ["diff", "--name-only", "--end-of-options", commit, rev]);
|
|
465
819
|
if (!out.ok) throw failed("diff", out);
|
|
466
820
|
return out.stdout.split(/\r?\n/).filter((line) => line !== "");
|
|
467
821
|
}),
|
|
468
822
|
diffSince: (commit, path) => once(`diff\0${commit}\0${path}`, async () => {
|
|
469
|
-
const
|
|
823
|
+
const against = rev === "HEAD" ? [commit] : [commit, rev];
|
|
824
|
+
const out = await run(root, ["diff", "--end-of-options", ...against, "--", path]);
|
|
470
825
|
if (!out.ok) throw failed("diff", out);
|
|
471
826
|
return out.stdout;
|
|
472
827
|
}),
|
|
@@ -477,7 +832,8 @@ function gitClient(root) {
|
|
|
477
832
|
`--format=%H${UNIT}%s`,
|
|
478
833
|
"--topo-order",
|
|
479
834
|
`-n${String(cap + 1)}`,
|
|
480
|
-
"
|
|
835
|
+
"--end-of-options",
|
|
836
|
+
rev,
|
|
481
837
|
"--",
|
|
482
838
|
path
|
|
483
839
|
]);
|
|
@@ -495,316 +851,151 @@ function gitClient(root) {
|
|
|
495
851
|
};
|
|
496
852
|
}
|
|
497
853
|
var UNIT = "";
|
|
498
|
-
var GIT_UNAVAILABLE_HISTORY = "git is not available here, so citations are checked without history: no never-true, no reanchored claims, no diffs, no commit subjects.";
|
|
499
|
-
var PAGE_HISTORY_UNAVAILABLE = "the page history ends before the pin held; use fetch-depth: 0 to tell reanchored claims from changed ones";
|
|
500
|
-
var
|
|
501
|
-
var
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
// src/cite/core/history.ts
|
|
516
|
-
var MAX_PAGE_COMMITS = 256;
|
|
517
|
-
function stripMarkers(lines, format) {
|
|
518
|
-
return lines.filter((line) => !isMarkerLine(line, format));
|
|
519
|
-
}
|
|
520
|
-
function claimWords(lines, format) {
|
|
521
|
-
return stripMarkers(lines, format).join(" ").replace(/\s+/g, " ").trim();
|
|
522
|
-
}
|
|
523
|
-
function sentencesOf(text) {
|
|
524
|
-
return text.split(/(?<=[.!?])\s+/).map((sentence) => sentence.replace(/\s+/g, " ").trim().toLowerCase()).filter((sentence) => sentence !== "");
|
|
525
|
-
}
|
|
526
|
-
function sharesSentence(a, b) {
|
|
527
|
-
const left = new Set(sentencesOf(a));
|
|
528
|
-
return sentencesOf(b).some((sentence) => left.has(sentence));
|
|
529
|
-
}
|
|
530
|
-
function wordSet(text) {
|
|
531
|
-
return new Set(
|
|
532
|
-
text.toLowerCase().split(/\s+/).filter((word) => word !== "")
|
|
533
|
-
);
|
|
534
|
-
}
|
|
535
|
-
function wordShare(was, now) {
|
|
536
|
-
const left = wordSet(was);
|
|
537
|
-
if (left.size === 0) return 1;
|
|
538
|
-
const right = wordSet(now);
|
|
539
|
-
let held = 0;
|
|
540
|
-
for (const word of left) if (right.has(word)) held++;
|
|
541
|
-
return held / left.size;
|
|
542
|
-
}
|
|
543
|
-
function holdsWords(outer, inner) {
|
|
544
|
-
if (inner === "") return true;
|
|
545
|
-
if (outer === inner) return true;
|
|
546
|
-
if (outer.startsWith(`${inner} `)) return true;
|
|
547
|
-
if (outer.endsWith(` ${inner}`)) return true;
|
|
548
|
-
return outer.includes(` ${inner} `);
|
|
549
|
-
}
|
|
550
|
-
function runsHolding(lines, format, bodyLine, inner) {
|
|
551
|
-
if (inner === "") return [];
|
|
552
|
-
let text = "";
|
|
553
|
-
const at = [];
|
|
554
|
-
for (let n = Math.max(bodyLine, 1); n <= lines.length; n++) {
|
|
555
|
-
const line = lines[n - 1] ?? "";
|
|
556
|
-
if (isMarkerLine(line, format)) continue;
|
|
557
|
-
const words = line.replace(/\s+/g, " ").trim();
|
|
558
|
-
if (words === "") continue;
|
|
559
|
-
if (text !== "") {
|
|
560
|
-
text += " ";
|
|
561
|
-
at.push(n);
|
|
562
|
-
}
|
|
563
|
-
for (let i = 0; i < words.length; i++) at.push(n);
|
|
564
|
-
text += words;
|
|
565
|
-
}
|
|
566
|
-
const out = [];
|
|
567
|
-
let from = 0;
|
|
568
|
-
for (; ; ) {
|
|
569
|
-
const found = text.indexOf(inner, from);
|
|
570
|
-
if (found === -1) break;
|
|
571
|
-
from = found + 1;
|
|
572
|
-
const before = found === 0 ? " " : text[found - 1];
|
|
573
|
-
const afterAt = found + inner.length;
|
|
574
|
-
const after = afterAt === text.length ? " " : text[afterAt];
|
|
575
|
-
if (before !== " " || after !== " ") continue;
|
|
576
|
-
const start = at[found];
|
|
577
|
-
const end = at[afterAt - 1];
|
|
578
|
-
if (start === void 0 || end === void 0) continue;
|
|
579
|
-
if (!out.some((span) => span.start === start && span.end === end)) out.push({ start, end });
|
|
580
|
-
}
|
|
581
|
-
return out.filter(
|
|
582
|
-
(span) => !out.some(
|
|
583
|
-
(other) => (other.start !== span.start || other.end !== span.end) && other.start >= span.start && other.end <= span.end
|
|
584
|
-
)
|
|
585
|
-
);
|
|
586
|
-
}
|
|
587
|
-
function bounds(line) {
|
|
588
|
-
return line === void 0 || line.trim() === "" || ANY_FENCE.test(line);
|
|
854
|
+
var GIT_UNAVAILABLE_HISTORY = "git is not available here, so citations are checked without history: no never-true, no reanchored claims, no diffs, no commit subjects.";
|
|
855
|
+
var PAGE_HISTORY_UNAVAILABLE = "the page history ends before the pin held; use fetch-depth: 0 to tell reanchored claims from changed ones";
|
|
856
|
+
var SOURCE_HISTORY_UNAVAILABLE = "the source history ends before the pin held; use fetch-depth: 0 to tell never-true from changed";
|
|
857
|
+
var SHALLOW_RECOMMIT = "this clone is shallow, so --recommit re-recorded only commits that do not contain their lines. Fetch full history to check the rest.";
|
|
858
|
+
var GIT_UNAVAILABLE_COMMIT = "git is not available here, so the citation records no commit.";
|
|
859
|
+
function noGit() {
|
|
860
|
+
return {
|
|
861
|
+
available: () => Promise.resolve(false),
|
|
862
|
+
head: () => Promise.resolve(null),
|
|
863
|
+
lsFiles: () => Promise.resolve([]),
|
|
864
|
+
showFile: () => Promise.resolve({ missing: "commit" }),
|
|
865
|
+
subjectsSince: () => Promise.resolve([]),
|
|
866
|
+
diffSince: () => Promise.resolve(""),
|
|
867
|
+
changedSince: () => Promise.resolve([]),
|
|
868
|
+
pageCommits: () => Promise.resolve({ commits: [], shallow: false, truncated: false })
|
|
869
|
+
};
|
|
589
870
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
871
|
+
var LOG_BUFFER = 1024 * 1024 * 1024;
|
|
872
|
+
var ZERO = /^0+$/;
|
|
873
|
+
function gitFailed(verb, outcome) {
|
|
874
|
+
return new CiteError(`git ${verb} failed: ${outcome.stderr.trim() || outcome.message}`);
|
|
593
875
|
}
|
|
594
|
-
function
|
|
595
|
-
const
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
876
|
+
async function firstParentLog(root) {
|
|
877
|
+
const out = await run(
|
|
878
|
+
root,
|
|
879
|
+
[
|
|
880
|
+
"log",
|
|
881
|
+
"--first-parent",
|
|
882
|
+
"--diff-merges=first-parent",
|
|
883
|
+
"--root",
|
|
884
|
+
"-M",
|
|
885
|
+
"--raw",
|
|
886
|
+
"--no-abbrev",
|
|
887
|
+
"-z",
|
|
888
|
+
"--format=%x01%H%x02%ct%x02%s",
|
|
889
|
+
"HEAD"
|
|
890
|
+
],
|
|
891
|
+
LOG_BUFFER
|
|
602
892
|
);
|
|
603
|
-
if (
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
if (split !== void 0) {
|
|
626
|
-
const text = unitText(then.lines, split);
|
|
627
|
-
if (hashLines(text.join("\n")) === pin) {
|
|
628
|
-
return { kind: "found", span: movedUnit(split), lines: text };
|
|
893
|
+
if (!out.ok) throw gitFailed("log", out);
|
|
894
|
+
const commits = [];
|
|
895
|
+
for (const record of out.stdout.split("")) {
|
|
896
|
+
if (record === "") continue;
|
|
897
|
+
const end = record.indexOf("\0");
|
|
898
|
+
const [sha, time, ...subject] = (end === -1 ? record : record.slice(0, end)).split("");
|
|
899
|
+
if (sha === void 0 || time === void 0) continue;
|
|
900
|
+
const tokens = end === -1 ? [] : record.slice(end + 1).replace(/^\n/, "").split("\0");
|
|
901
|
+
const changes = [];
|
|
902
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
903
|
+
const meta = tokens[i];
|
|
904
|
+
if (meta === void 0 || !meta.startsWith(":")) continue;
|
|
905
|
+
const [, mode, , blob, status] = meta.slice(1).split(" ");
|
|
906
|
+
const path = tokens[++i];
|
|
907
|
+
if (path === void 0 || blob === void 0 || status === void 0) continue;
|
|
908
|
+
const added = ZERO.test(blob) ? { path } : { path, blob, ...mode === void 0 ? {} : { mode } };
|
|
909
|
+
if (status.startsWith("R") || status.startsWith("C")) {
|
|
910
|
+
const to = tokens[++i];
|
|
911
|
+
if (to === void 0) continue;
|
|
912
|
+
if (status.startsWith("R")) changes.push({ path });
|
|
913
|
+
changes.push({ ...added, path: to, ...status.startsWith("R") ? { from: path } : {} });
|
|
914
|
+
} else changes.push(added);
|
|
629
915
|
}
|
|
916
|
+
commits.push({ sha, time: Number(time), subject: subject.join(""), changes });
|
|
630
917
|
}
|
|
631
|
-
return
|
|
632
|
-
}
|
|
633
|
-
function
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
918
|
+
return commits.reverse();
|
|
919
|
+
}
|
|
920
|
+
async function topLevel(root) {
|
|
921
|
+
const out = await run(root, ["rev-parse", "--show-toplevel"]);
|
|
922
|
+
return out.ok ? out.stdout.trim() : null;
|
|
923
|
+
}
|
|
924
|
+
async function commitGraph(root) {
|
|
925
|
+
const out = await run(root, ["log", "--format=%H %ct %P", "HEAD"], LOG_BUFFER);
|
|
926
|
+
if (!out.ok) throw gitFailed("log", out);
|
|
927
|
+
const graph = /* @__PURE__ */ new Map();
|
|
928
|
+
for (const line of out.stdout.split(/\r?\n/)) {
|
|
929
|
+
const [sha, time, ...parents] = line.trim().split(" ");
|
|
930
|
+
if (sha === void 0 || sha === "" || time === void 0) continue;
|
|
931
|
+
graph.set(sha, { time: Number(time), parents: parents.filter((p) => p !== "") });
|
|
643
932
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
933
|
+
return graph;
|
|
934
|
+
}
|
|
935
|
+
async function tagCommits(root) {
|
|
936
|
+
const out = await run(root, [
|
|
937
|
+
"for-each-ref",
|
|
938
|
+
"--format=%(refname:strip=2) %(objectname) %(*objectname)",
|
|
939
|
+
"refs/tags"
|
|
940
|
+
]);
|
|
941
|
+
if (!out.ok) throw gitFailed("for-each-ref", out);
|
|
942
|
+
const tags = [];
|
|
943
|
+
for (const line of out.stdout.split(/\r?\n/)) {
|
|
944
|
+
const [name, object, peeled] = line.trim().split(" ");
|
|
945
|
+
if (name === void 0 || name === "" || object === void 0) continue;
|
|
946
|
+
tags.push({ name, commit: peeled !== void 0 && peeled !== "" ? peeled : object });
|
|
649
947
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
948
|
+
return tags;
|
|
949
|
+
}
|
|
950
|
+
function blobReader(root) {
|
|
951
|
+
const child = spawn("git", ["cat-file", "--batch"], {
|
|
952
|
+
cwd: root,
|
|
953
|
+
windowsHide: true,
|
|
954
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
955
|
+
});
|
|
956
|
+
const waiting = [];
|
|
957
|
+
let buffer = Buffer.alloc(0);
|
|
958
|
+
const drain = () => {
|
|
959
|
+
for (; ; ) {
|
|
960
|
+
const next = waiting[0];
|
|
961
|
+
const nl = buffer.indexOf(10);
|
|
962
|
+
if (next === void 0 || nl === -1) return;
|
|
963
|
+
const header = buffer.subarray(0, nl).toString("utf8").split(" ");
|
|
964
|
+
const size = Number(header[2]);
|
|
965
|
+
if (header[1] === "missing" || !Number.isInteger(size)) {
|
|
966
|
+
buffer = buffer.subarray(nl + 1);
|
|
967
|
+
waiting.shift();
|
|
968
|
+
next.reject(new CiteError(`git cat-file failed: ${header.join(" ")}`));
|
|
969
|
+
continue;
|
|
654
970
|
}
|
|
971
|
+
if (buffer.length < nl + 2 + size) return;
|
|
972
|
+
const text = buffer.subarray(nl + 1, nl + 1 + size).toString("utf8");
|
|
973
|
+
buffer = buffer.subarray(nl + 2 + size);
|
|
974
|
+
waiting.shift();
|
|
975
|
+
next.resolve(text);
|
|
655
976
|
}
|
|
656
|
-
}
|
|
657
|
-
return { kind: "absent" };
|
|
658
|
-
}
|
|
659
|
-
async function stillWritten(input, commit, pageText) {
|
|
660
|
-
const pin = input.entry.citation.claim?.integrity;
|
|
661
|
-
if (pin === void 0) return { stop: true, born: true };
|
|
662
|
-
const manifest = input.manifest;
|
|
663
|
-
if (manifest !== void 0) {
|
|
664
|
-
const shown = await input.git.showFile(commit, manifest);
|
|
665
|
-
const held2 = "text" in shown && shown.text.includes(pin);
|
|
666
|
-
return { stop: !held2, born: !held2 };
|
|
667
|
-
}
|
|
668
|
-
const held = pageText.includes(pin);
|
|
669
|
-
return { stop: false, born: !held };
|
|
670
|
-
}
|
|
671
|
-
async function claimHistory(input) {
|
|
672
|
-
const { git, path } = input;
|
|
673
|
-
if (git.pageCommits === void 0) return { kind: "none" };
|
|
674
|
-
if (!await git.available()) return { kind: "none" };
|
|
675
|
-
const cap = input.cap ?? MAX_PAGE_COMMITS;
|
|
676
|
-
const history = await git.pageCommits(path, cap);
|
|
677
|
-
const { commits } = history;
|
|
678
|
-
if (commits.length === 0) return { kind: "none" };
|
|
679
|
-
const format = input.page.format;
|
|
680
|
-
const baselineAt = (index, then, found) => {
|
|
681
|
-
if (found.kind !== "found") return { kind: "none" };
|
|
682
|
-
const commit = commits[index];
|
|
683
|
-
if (commit === void 0) return { kind: "none" };
|
|
684
|
-
return {
|
|
685
|
-
kind: "baseline",
|
|
686
|
-
commit: commit.sha,
|
|
687
|
-
commitsSince: commits.slice(0, index).map((c) => c.subject),
|
|
688
|
-
words: claimWords(found.lines, format),
|
|
689
|
-
pageWords: claimWords(then.lines.slice(then.page.bodyLine - 1), format),
|
|
690
|
-
lines: found.lines,
|
|
691
|
-
at: spellLines(found.span)
|
|
692
|
-
};
|
|
693
977
|
};
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
let born = false;
|
|
697
|
-
for (let i = 0; i < commits.length; i++) {
|
|
698
|
-
const commit = commits[i];
|
|
699
|
-
if (commit === void 0) continue;
|
|
700
|
-
const shown = await git.showFile(commit.sha, path);
|
|
701
|
-
if (!("text" in shown)) {
|
|
702
|
-
ended = shown.missing === "commit" ? "unavailable" : "birth";
|
|
703
|
-
break;
|
|
704
|
-
}
|
|
705
|
-
const then = readThen(input, shown.text);
|
|
706
|
-
if (then === void 0) {
|
|
707
|
-
ended = "birth";
|
|
708
|
-
break;
|
|
709
|
-
}
|
|
710
|
-
examined.push(then);
|
|
711
|
-
const found = anchorHeldAt(input, then);
|
|
712
|
-
if (found.kind === "found") return baselineAt(i, then, found);
|
|
713
|
-
const written = await stillWritten(input, commit.sha, shown.text);
|
|
714
|
-
if (written.born) born = true;
|
|
715
|
-
if (written.stop) {
|
|
716
|
-
ended = "birth";
|
|
717
|
-
break;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
for (const [i, then] of examined.entries()) {
|
|
721
|
-
const found = windowHeldAt(input, then);
|
|
722
|
-
if (found.kind === "found") return baselineAt(i, then, found);
|
|
723
|
-
}
|
|
724
|
-
if (ended === "birth" || born) return { kind: "none" };
|
|
725
|
-
if (ended === "unavailable") return { kind: "unavailable" };
|
|
726
|
-
return history.truncated || history.shallow ? { kind: "unavailable" } : { kind: "none" };
|
|
727
|
-
}
|
|
728
|
-
function claimDiff(input) {
|
|
729
|
-
const a = input.was.lines;
|
|
730
|
-
const b = input.now.lines;
|
|
731
|
-
let head = 0;
|
|
732
|
-
while (head < a.length && head < b.length && a[head] === b[head]) head++;
|
|
733
|
-
let tail = 0;
|
|
734
|
-
while (tail < a.length - head && tail < b.length - head && a[a.length - 1 - tail] === b[b.length - 1 - tail]) {
|
|
735
|
-
tail++;
|
|
736
|
-
}
|
|
737
|
-
const out = [
|
|
738
|
-
`--- ${input.file}@${shortCommit(input.commit)}:${input.was.at}`,
|
|
739
|
-
`+++ ${input.file}:${input.now.at}`
|
|
740
|
-
];
|
|
741
|
-
for (const line of a.slice(0, head)) out.push(` ${line}`);
|
|
742
|
-
for (const line of a.slice(head, a.length - tail)) out.push(`-${line}`);
|
|
743
|
-
for (const line of b.slice(head, b.length - tail)) out.push(`+${line}`);
|
|
744
|
-
for (const line of a.slice(a.length - tail)) out.push(` ${line}`);
|
|
745
|
-
return out.join("\n");
|
|
746
|
-
}
|
|
747
|
-
function refineClaim(input) {
|
|
748
|
-
const { claim, history, entry, page, lines } = input;
|
|
749
|
-
if (history.kind === "unavailable") return { ...claim, historyAvailable: false };
|
|
750
|
-
if (history.kind === "none") return claim;
|
|
751
|
-
const format = page.format;
|
|
752
|
-
const base = {
|
|
753
|
-
...claim,
|
|
754
|
-
commitSha: history.commit,
|
|
755
|
-
historyAvailable: true,
|
|
756
|
-
commitsSince: history.commitsSince,
|
|
757
|
-
baselineText: history.lines
|
|
978
|
+
const failAll = (error) => {
|
|
979
|
+
for (const next of waiting.splice(0)) next.reject(error);
|
|
758
980
|
};
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
981
|
+
child.stdout.on("data", (chunk) => {
|
|
982
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
983
|
+
drain();
|
|
984
|
+
});
|
|
985
|
+
child.on("error", failAll);
|
|
986
|
+
child.on("close", () => {
|
|
987
|
+
failAll(new CiteError("git cat-file ended early"));
|
|
988
|
+
});
|
|
989
|
+
return {
|
|
990
|
+
read: (blob) => new Promise((resolve4, reject) => {
|
|
991
|
+
waiting.push({ resolve: resolve4, reject });
|
|
992
|
+
child.stdin.write(`${blob}
|
|
993
|
+
`);
|
|
994
|
+
}),
|
|
995
|
+
close: () => {
|
|
996
|
+
child.stdin.end();
|
|
997
|
+
}
|
|
767
998
|
};
|
|
768
|
-
if (entry.citation.quote === true) {
|
|
769
|
-
const now2 = claim.text ?? [];
|
|
770
|
-
const same = stripMarkers(now2, format).join("\n") === stripMarkers(history.lines, format).join("\n");
|
|
771
|
-
const at = claim.fileLines ?? history.at;
|
|
772
|
-
return withDiff(same ? { ...base, status: "reanchored" } : base, { at, lines: now2 });
|
|
773
|
-
}
|
|
774
|
-
if (entry.citation.claim?.lines === void 0) {
|
|
775
|
-
const now2 = claim.text ?? [];
|
|
776
|
-
const w12 = claimWords(now2, format);
|
|
777
|
-
const at = claim.fileLines ?? history.at;
|
|
778
|
-
const held = holdsWords(w12, history.words) && holdsWords(history.pageWords, w12);
|
|
779
|
-
return withDiff(held ? { ...base, status: "reanchored" } : base, { at, lines: now2 });
|
|
780
|
-
}
|
|
781
|
-
const runs = runsHolding(lines, format, page.bodyLine, history.words);
|
|
782
|
-
const [only] = runs;
|
|
783
|
-
if (runs.length > 1) {
|
|
784
|
-
return {
|
|
785
|
-
...claim,
|
|
786
|
-
status: "moved-ambiguous",
|
|
787
|
-
candidates: runs.map((span) => spellLines(toBodyLines(span, page.bodyLine))),
|
|
788
|
-
candidateFileLines: runs.map(spellLines)
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
if (only === void 0) {
|
|
792
|
-
return withDiff(base, { at: claim.fileLines ?? history.at, lines: claim.text ?? [] });
|
|
793
|
-
}
|
|
794
|
-
const now = lines.slice(only.start - 1, only.end);
|
|
795
|
-
const w1 = claimWords(now, format);
|
|
796
|
-
if (!holdsWords(history.pageWords, w1)) {
|
|
797
|
-
return withDiff(base, { at: claim.fileLines ?? history.at, lines: claim.text ?? [] });
|
|
798
|
-
}
|
|
799
|
-
return withDiff(
|
|
800
|
-
{
|
|
801
|
-
...base,
|
|
802
|
-
status: "reanchored",
|
|
803
|
-
newLines: spellLines(toBodyLines(only, page.bodyLine)),
|
|
804
|
-
newFileLines: spellLines(only)
|
|
805
|
-
},
|
|
806
|
-
{ at: spellLines(only), lines: now }
|
|
807
|
-
);
|
|
808
999
|
}
|
|
809
1000
|
|
|
810
1001
|
// src/cite/core/check-page.ts
|
|
@@ -1008,7 +1199,7 @@ async function checkCitations(page, opts) {
|
|
|
1008
1199
|
}
|
|
1009
1200
|
findings.push(...findingsFor(results, severity));
|
|
1010
1201
|
for (const finding of findings) finding.guidance = guidanceFor(finding.rule);
|
|
1011
|
-
const wantsSourceHistory = checkSources && read.citations.some(({ citation }) => citation.source["commit-sha"] !== void 0);
|
|
1202
|
+
const wantsSourceHistory = checkSources && (read.citations.some(({ citation }) => citation.source["commit-sha"] !== void 0) || results.some((r) => r.source.status !== "current"));
|
|
1012
1203
|
const wantsClaimHistory = results.some((r) => r.claim?.status === "changed");
|
|
1013
1204
|
if (wantsSourceHistory && !await client.available()) notices.push(GIT_UNAVAILABLE_HISTORY);
|
|
1014
1205
|
else if (wantsClaimHistory && !await pageGit.available()) {
|
|
@@ -1017,11 +1208,8 @@ async function checkCitations(page, opts) {
|
|
|
1017
1208
|
if (results.some((r) => r.claim?.historyAvailable === false)) {
|
|
1018
1209
|
notices.push(PAGE_HISTORY_UNAVAILABLE);
|
|
1019
1210
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
notices.push(
|
|
1023
|
-
`commit ${unavailable.source.commitSha.slice(0, 7)} not found in history; use fetch-depth: 0 to enable never-true and diffs`
|
|
1024
|
-
);
|
|
1211
|
+
if (results.some((r) => r.source.historyAvailable === false)) {
|
|
1212
|
+
notices.push(SOURCE_HISTORY_UNAVAILABLE);
|
|
1025
1213
|
}
|
|
1026
1214
|
const budget = String(MOVE_BUDGET_BYTES / (1024 * 1024));
|
|
1027
1215
|
if (results.some((r) => r.source.truncatedSearch === true && r.source.truncatedAcross !== true)) {
|
|
@@ -1621,15 +1809,36 @@ export {
|
|
|
1621
1809
|
gitClient,
|
|
1622
1810
|
GIT_UNAVAILABLE_HISTORY,
|
|
1623
1811
|
PAGE_HISTORY_UNAVAILABLE,
|
|
1812
|
+
SOURCE_HISTORY_UNAVAILABLE,
|
|
1624
1813
|
SHALLOW_RECOMMIT,
|
|
1625
1814
|
GIT_UNAVAILABLE_COMMIT,
|
|
1626
1815
|
noGit,
|
|
1816
|
+
firstParentLog,
|
|
1817
|
+
topLevel,
|
|
1818
|
+
commitGraph,
|
|
1819
|
+
tagCommits,
|
|
1820
|
+
blobReader,
|
|
1821
|
+
MAX_PAGE_COMMITS,
|
|
1822
|
+
stripMarkers,
|
|
1823
|
+
claimWords,
|
|
1824
|
+
sentencesOf,
|
|
1825
|
+
sharesSentence,
|
|
1826
|
+
wordShare,
|
|
1827
|
+
holdsWords,
|
|
1828
|
+
runsHolding,
|
|
1829
|
+
claimHistory,
|
|
1830
|
+
claimDiff,
|
|
1831
|
+
refineClaim,
|
|
1627
1832
|
encryptSourcePath,
|
|
1628
1833
|
decryptSourcePath,
|
|
1629
1834
|
buildSourceIndex,
|
|
1630
1835
|
sourceIndexFor,
|
|
1836
|
+
resolveSourcePath,
|
|
1837
|
+
createSourceCache,
|
|
1631
1838
|
readSource,
|
|
1632
1839
|
historyOf,
|
|
1840
|
+
sourceBaseline,
|
|
1841
|
+
arrivalOf,
|
|
1633
1842
|
classifyCitation,
|
|
1634
1843
|
CITATIONS_KEY,
|
|
1635
1844
|
urlManifestRefusal,
|
|
@@ -1638,17 +1847,6 @@ export {
|
|
|
1638
1847
|
orphanRefusal,
|
|
1639
1848
|
duplicateJoinRefusal,
|
|
1640
1849
|
sidecarsFor,
|
|
1641
|
-
MAX_PAGE_COMMITS,
|
|
1642
|
-
stripMarkers,
|
|
1643
|
-
claimWords,
|
|
1644
|
-
sentencesOf,
|
|
1645
|
-
sharesSentence,
|
|
1646
|
-
wordShare,
|
|
1647
|
-
holdsWords,
|
|
1648
|
-
runsHolding,
|
|
1649
|
-
claimHistory,
|
|
1650
|
-
claimDiff,
|
|
1651
|
-
refineClaim,
|
|
1652
1850
|
checkCitations,
|
|
1653
1851
|
joinHits,
|
|
1654
1852
|
prepareRun,
|
|
@@ -1658,4 +1856,4 @@ export {
|
|
|
1658
1856
|
sayNotices,
|
|
1659
1857
|
runCheck
|
|
1660
1858
|
};
|
|
1661
|
-
//# sourceMappingURL=chunk-
|
|
1859
|
+
//# sourceMappingURL=chunk-6DYFWAZA.js.map
|