@maycombhq/atticus 2.0.0-beta.22 → 2.0.0-beta.24

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 (289) hide show
  1. package/dist/bin.js +12 -7
  2. package/dist/{chunk-J2JAKCIW.js → chunk-25CUJJTP.js} +511 -291
  3. package/dist/chunk-26AB2WNW.js +62 -0
  4. package/dist/{chunk-VBTP56CE.js → chunk-2ITYURTR.js} +9 -8
  5. package/dist/{chunk-6ZJ5A7AF.js → chunk-2JHE75RW.js} +13 -11
  6. package/dist/{chunk-QFWA2DPH.js → chunk-37UTWGU4.js} +8 -6
  7. package/dist/{chunk-VW62D6QE.js → chunk-3BEGKSDW.js} +14 -12
  8. package/dist/{chunk-3RM4UK6W.js → chunk-3FGQFDS4.js} +20 -18
  9. package/dist/{chunk-23XVSEV5.js → chunk-3NS4RS3C.js} +20 -18
  10. package/dist/{chunk-FSMSFDLD.js → chunk-3TGX4SJ3.js} +10 -7
  11. package/dist/{chunk-7JITZFJC.js → chunk-3UMKLB6P.js} +7 -5
  12. package/dist/chunk-3VS7RNEB.js +96 -0
  13. package/dist/{chunk-AJYXNTNZ.js → chunk-3XCCT2GR.js} +167 -42
  14. package/dist/{chunk-XERYFDB5.js → chunk-3XZRYQWU.js} +38 -34
  15. package/dist/{chunk-FUJM6RTF.js → chunk-432FGEVB.js} +9 -7
  16. package/dist/{chunk-SFUP7TTO.js → chunk-44QUCNPH.js} +7 -5
  17. package/dist/{chunk-O5PXQR67.js → chunk-4CS3PMIM.js} +15 -13
  18. package/dist/{chunk-RGERPOIV.js → chunk-4DCIUKIE.js} +22 -12
  19. package/dist/{chunk-RLDGWLQ7.js → chunk-4DX4DIND.js} +9 -7
  20. package/dist/chunk-4MNMOUU7.js +108 -0
  21. package/dist/{chunk-SLXZOMA6.js → chunk-4RKIOUPA.js} +9 -7
  22. package/dist/{chunk-AJQ72EBM.js → chunk-532HDXMM.js} +9 -7
  23. package/dist/{chunk-CADWLE2T.js → chunk-5EIKOU7L.js} +6 -4
  24. package/dist/{chunk-CQDGOPGH.js → chunk-5FPAKAGE.js} +7 -5
  25. package/dist/{chunk-IVBOQAGB.js → chunk-5FUFVNXB.js} +27 -3
  26. package/dist/{chunk-UUU4CLJG.js → chunk-5MKV4TV6.js} +5 -1
  27. package/dist/{chunk-ZQXZ2SES.js → chunk-5ORLKITZ.js} +23 -21
  28. package/dist/{chunk-OHVTTOPS.js → chunk-5PSKLTBR.js} +3 -3
  29. package/dist/{chunk-RUGXBPWI.js → chunk-5QF5W5P2.js} +10 -10
  30. package/dist/{chunk-BPK5P77O.js → chunk-5Z7L2TSR.js} +3 -3
  31. package/dist/{chunk-L27SV425.js → chunk-66DWUSNY.js} +22 -20
  32. package/dist/{chunk-JAVI7JSP.js → chunk-6FIYEB7M.js} +25 -22
  33. package/dist/{chunk-VY72R2XZ.js → chunk-6OZAQPU5.js} +532 -358
  34. package/dist/{chunk-AFWUDXEM.js → chunk-6TNQO76I.js} +34 -17
  35. package/dist/{chunk-WF7B67YE.js → chunk-6UTD5RQH.js} +18 -16
  36. package/dist/{chunk-HNM2YQT2.js → chunk-775FMPUB.js} +7 -7
  37. package/dist/{chunk-7ASNL4Q4.js → chunk-77AZRGWE.js} +19 -16
  38. package/dist/{chunk-WKUJ3KPV.js → chunk-7HWCEDPX.js} +7 -5
  39. package/dist/{chunk-G6X77UJZ.js → chunk-7U46TCRZ.js} +25 -22
  40. package/dist/{chunk-O45HFTFS.js → chunk-A3NUZJFI.js} +4 -2
  41. package/dist/{chunk-UPOY4YSQ.js → chunk-A4VDFIMR.js} +14 -12
  42. package/dist/{chunk-EMRIQUND.js → chunk-A53IYUCR.js} +87 -29
  43. package/dist/{chunk-S4PMJU6H.js → chunk-A6ZG3UOS.js} +108 -50
  44. package/dist/{chunk-PMUAJGLI.js → chunk-AAY6VPPO.js} +18 -16
  45. package/dist/{chunk-MG4ZL5RW.js → chunk-ABDE5IRC.js} +18 -16
  46. package/dist/{chunk-T6DQR5TV.js → chunk-AM7PYKVP.js} +15 -13
  47. package/dist/{chunk-SFSPGFCV.js → chunk-ANUMIPF6.js} +22 -20
  48. package/dist/{chunk-VTZMAJ3W.js → chunk-ASFRT33J.js} +11 -9
  49. package/dist/{chunk-7FTTA3HD.js → chunk-AWDCVZYO.js} +9 -7
  50. package/dist/{chunk-KFAVQZSX.js → chunk-B63NWU3P.js} +14 -12
  51. package/dist/{chunk-YYY3AZFE.js → chunk-BBZ6UKN3.js} +16 -5
  52. package/dist/{chunk-Q4K5WB2W.js → chunk-BFQ5IKQA.js} +12 -10
  53. package/dist/{chunk-ZFL7NY4F.js → chunk-BLVFHN3C.js} +73 -42
  54. package/dist/{chunk-MO6P2JZH.js → chunk-BQXAHIZ6.js} +10 -8
  55. package/dist/{chunk-Y2EQNWKV.js → chunk-BTS56NV7.js} +91 -41
  56. package/dist/{chunk-UGUP3ZM6.js → chunk-BWYW533C.js} +18 -16
  57. package/dist/{chunk-O7FDLW7L.js → chunk-BYKWWSXL.js} +14 -12
  58. package/dist/chunk-C7BB6IQT.js +147 -0
  59. package/dist/{chunk-JLUCKAEL.js → chunk-CCQWQFOT.js} +19 -17
  60. package/dist/{chunk-SYV5LHML.js → chunk-CCQZN6W3.js} +35 -33
  61. package/dist/{chunk-UCROWG2D.js → chunk-CFSBBLDD.js} +28 -25
  62. package/dist/{chunk-EIPTLPFC.js → chunk-CFSHLQPK.js} +26 -24
  63. package/dist/{chunk-2IIMFOPM.js → chunk-CI4D6VSU.js} +20 -18
  64. package/dist/{chunk-66PPNOON.js → chunk-CKRPMRFQ.js} +28 -25
  65. package/dist/{chunk-IUPG3UKI.js → chunk-CNF2EZ6S.js} +191 -125
  66. package/dist/chunk-CTJHEG6A.js +97 -0
  67. package/dist/{chunk-DOBQKHIF.js → chunk-CU7ZK7KP.js} +30 -29
  68. package/dist/{chunk-745DAZ4L.js → chunk-CZ75S2EZ.js} +886 -313
  69. package/dist/{chunk-LGFL54FP.js → chunk-D5CJEKZI.js} +11 -4
  70. package/dist/{chunk-PBPBMP2B.js → chunk-D5ZC7IMC.js} +5 -3
  71. package/dist/{chunk-LZ7NUC62.js → chunk-D63NU53X.js} +20 -18
  72. package/dist/{chunk-BO4KX37X.js → chunk-DCQSPSXU.js} +28 -23
  73. package/dist/{chunk-WXFLMQSR.js → chunk-DCRZ3OQ7.js} +8 -6
  74. package/dist/chunk-DD2AXECF.js +41 -0
  75. package/dist/{chunk-4EURQWQD.js → chunk-DF6DPCW2.js} +16 -14
  76. package/dist/{chunk-53T4O55J.js → chunk-DH3EQMIA.js} +5 -3
  77. package/dist/{chunk-ZX57KSEQ.js → chunk-DIXA74N7.js} +5 -3
  78. package/dist/{chunk-6ZGLAACW.js → chunk-DIYNRYXW.js} +2 -2
  79. package/dist/chunk-DYDNW4O6.js +52 -0
  80. package/dist/{chunk-P2V7QW4D.js → chunk-E7YDJH6B.js} +16 -14
  81. package/dist/chunk-EEKQI3U4.js +45 -0
  82. package/dist/{chunk-GZY6RUZ6.js → chunk-EHF2MBGR.js} +9 -4
  83. package/dist/chunk-EHXDB3SA.js +25 -0
  84. package/dist/{chunk-PJSJPMJI.js → chunk-ENZ3PI7L.js} +3 -3
  85. package/dist/{chunk-E3ISYXO3.js → chunk-EPQQ2XVM.js} +16 -14
  86. package/dist/{chunk-7IGKHZ4Z.js → chunk-ESJALLOK.js} +222 -213
  87. package/dist/chunk-ETQSQ2EC.js +33 -0
  88. package/dist/{chunk-MFR5OPBD.js → chunk-EUMXLSW5.js} +14 -6
  89. package/dist/{chunk-BTY3HZBO.js → chunk-F63F4NKT.js} +18 -16
  90. package/dist/{chunk-ZFFYNRIO.js → chunk-FDL2JOLB.js} +26 -22
  91. package/dist/{chunk-5SJZW52K.js → chunk-FFDVAV56.js} +24 -22
  92. package/dist/chunk-FFYOZ7PF.js +27 -0
  93. package/dist/{chunk-RXPJMEOW.js → chunk-FGW5TLGM.js} +24 -19
  94. package/dist/{chunk-UPS2DGFC.js → chunk-FL53R4SW.js} +1 -1
  95. package/dist/chunk-FYWLB7PO.js +38 -0
  96. package/dist/{chunk-FFLNS6VP.js → chunk-G3W7GNEP.js} +24 -18
  97. package/dist/chunk-G3ZFEHCX.js +925 -0
  98. package/dist/{chunk-YHCMZC2J.js → chunk-G67GOK4S.js} +10 -8
  99. package/dist/{chunk-2F4CYZKJ.js → chunk-GCMDDVIE.js} +14 -9
  100. package/dist/{chunk-QKUJMING.js → chunk-GFYVVTKH.js} +10 -8
  101. package/dist/chunk-GJVCBTSO.js +20722 -0
  102. package/dist/{chunk-VCTWPLAO.js → chunk-GKZDHXC2.js} +8 -8
  103. package/dist/{chunk-5BD2KYLE.js → chunk-GQFUEUC7.js} +18 -16
  104. package/dist/chunk-GQPP4P2E.js +33 -0
  105. package/dist/{chunk-42SIDKEU.js → chunk-GS7N3RFG.js} +51 -32
  106. package/dist/{chunk-LJXMYKZJ.js → chunk-GXQYEIYM.js} +7 -5
  107. package/dist/{chunk-VNU26RCO.js → chunk-H5EQOSTC.js} +43 -33
  108. package/dist/{chunk-W7VWI2YH.js → chunk-H7KERB6Q.js} +7 -5
  109. package/dist/{chunk-OUBGGKDU.js → chunk-HGDBM3A5.js} +5 -3
  110. package/dist/{chunk-JENSEMXF.js → chunk-HI7ADE4E.js} +1 -1
  111. package/dist/{chunk-CXJ6FUKN.js → chunk-HNPKCRCE.js} +1010 -330
  112. package/dist/{chunk-FPJPLKDW.js → chunk-HRHXTLUM.js} +40 -16
  113. package/dist/{chunk-57TDNMI3.js → chunk-HRYI22QU.js} +17 -15
  114. package/dist/{chunk-LO6P2VYG.js → chunk-HWNFFCGB.js} +5 -3
  115. package/dist/{chunk-XI2LCCYQ.js → chunk-HXFZX2BI.js} +12 -8
  116. package/dist/{chunk-H7KM7LZE.js → chunk-HYHV2P3G.js} +16 -13
  117. package/dist/{chunk-X3WY6MN3.js → chunk-IB66ZLDN.js} +10 -8
  118. package/dist/{chunk-3NFFJL5D.js → chunk-IJQHBK76.js} +1 -1
  119. package/dist/{chunk-LQJPN536.js → chunk-IK6LHW3E.js} +6 -4
  120. package/dist/{chunk-DCZWQLYT.js → chunk-IOHRX4KF.js} +26 -21
  121. package/dist/{chunk-2GF7OLF3.js → chunk-IRXZKKCG.js} +21 -15
  122. package/dist/{chunk-Z5IA3WDR.js → chunk-IUBBEU6O.js} +160 -81
  123. package/dist/{chunk-W62H2XSO.js → chunk-IWPO5AUT.js} +29 -26
  124. package/dist/{chunk-BEVTIBRH.js → chunk-J4K4C4T5.js} +31 -15
  125. package/dist/{chunk-WERM6KPJ.js → chunk-JCEYOSST.js} +14 -6
  126. package/dist/{chunk-HYU5VLGA.js → chunk-JCG2EBNB.js} +1 -1
  127. package/dist/{chunk-UNAGJYET.js → chunk-JFBVIMGY.js} +14 -12
  128. package/dist/chunk-JJ4SCGRJ.js +43 -0
  129. package/dist/{chunk-2Q5EDGEO.js → chunk-JLYH2QOE.js} +7 -5
  130. package/dist/{chunk-X4CXA2IL.js → chunk-JMH6TCZJ.js} +23 -21
  131. package/dist/{chunk-6PPOWY5E.js → chunk-JUHZBZPZ.js} +17 -13
  132. package/dist/{chunk-GUX3PTYM.js → chunk-JVMNEI7B.js} +3 -3
  133. package/dist/chunk-JYJMIAFS.js +44 -0
  134. package/dist/{chunk-34S2WGOB.js → chunk-KIY2WCN7.js} +7 -3
  135. package/dist/chunk-KVVNAUIG.js +66 -0
  136. package/dist/{chunk-M32BLWDH.js → chunk-KYO5HT4G.js} +14 -12
  137. package/dist/chunk-L27KUL5B.js +38 -0
  138. package/dist/chunk-L3PIN47C.js +18 -0
  139. package/dist/{chunk-IH2XURVQ.js → chunk-L6Z6TMIK.js} +5 -5
  140. package/dist/{chunk-E6ZIEVOI.js → chunk-LAGZBQHK.js} +16 -13
  141. package/dist/chunk-LBG4GMOR.js +68 -0
  142. package/dist/{chunk-UF4GLFBX.js → chunk-LDKP7OWQ.js} +33 -24
  143. package/dist/{chunk-ZQ7SKESZ.js → chunk-LELM7X5H.js} +13 -11
  144. package/dist/{chunk-INQHESFB.js → chunk-LIB6AUZS.js} +6 -4
  145. package/dist/{chunk-H5HBGNXU.js → chunk-LIQWFDOZ.js} +6 -4
  146. package/dist/{chunk-TYQBFTBR.js → chunk-LKUTBQ2Y.js} +8 -6
  147. package/dist/{chunk-7BR7IPOH.js → chunk-LOCJHNZI.js} +10 -8
  148. package/dist/{chunk-SQV37XO2.js → chunk-LTIXFLYE.js} +6 -6
  149. package/dist/{chunk-3NWDLGG6.js → chunk-M3RWF7MC.js} +33 -29
  150. package/dist/chunk-MA6UK7GX.js +42 -0
  151. package/dist/{chunk-ISUAAMGS.js → chunk-MCE74XMF.js} +25 -16
  152. package/dist/{chunk-EGQRREQH.js → chunk-MDTAZ6NE.js} +37 -24
  153. package/dist/{chunk-ZZK56BLP.js → chunk-MMOMKHAX.js} +6 -4
  154. package/dist/{chunk-P32RUW3B.js → chunk-MOWUP33K.js} +49 -15
  155. package/dist/{chunk-UOR2DTHH.js → chunk-MPATOMY5.js} +18 -14
  156. package/dist/{chunk-LNBQOP7D.js → chunk-MQFSEGTU.js} +23 -21
  157. package/dist/{chunk-2Q56PQPS.js → chunk-MT3FNSXO.js} +4 -4
  158. package/dist/{chunk-FZOJFH7Q.js → chunk-MUY5MAGM.js} +15 -12
  159. package/dist/{chunk-7DOR27HL.js → chunk-MVXMISNA.js} +9 -7
  160. package/dist/{chunk-CX4RZ2KS.js → chunk-MWN7CBVL.js} +5 -3
  161. package/dist/{chunk-BXYMYEJ4.js → chunk-MZWM73S2.js} +18 -17
  162. package/dist/chunk-NBZ7RKX3.js +46 -0
  163. package/dist/{chunk-EPCJQQWD.js → chunk-NC56V6KQ.js} +6 -4
  164. package/dist/{chunk-7UOMVMFG.js → chunk-NN6AXKFX.js} +17 -15
  165. package/dist/{chunk-BIGDQDHD.js → chunk-NOU5IBLM.js} +6 -4
  166. package/dist/{chunk-LFGTYX5U.js → chunk-NQDHRT2H.js} +20 -18
  167. package/dist/{chunk-KDNTAPLX.js → chunk-NTEPBOAF.js} +6 -4
  168. package/dist/{chunk-LYBNHMVZ.js → chunk-NTOPAOBY.js} +3 -3
  169. package/dist/{chunk-R44CYFPV.js → chunk-NX5IPHI3.js} +19 -16
  170. package/dist/{chunk-GCWRWSU7.js → chunk-O4ZWZZZT.js} +6 -4
  171. package/dist/chunk-OCU5S2XG.js +36 -0
  172. package/dist/{chunk-SU74NDMQ.js → chunk-OKSRK2LJ.js} +19 -17
  173. package/dist/{chunk-XD75VZIH.js → chunk-OSWOIFRQ.js} +9 -7
  174. package/dist/{chunk-PKBHS4AA.js → chunk-OSZTENIA.js} +54 -21
  175. package/dist/{chunk-NDCF4R6S.js → chunk-OTUBMKSG.js} +10 -8
  176. package/dist/{chunk-THDMSZ3R.js → chunk-OYKNPZCV.js} +2837 -693
  177. package/dist/{chunk-ZQ3ON2VQ.js → chunk-OYTSRNSZ.js} +8 -6
  178. package/dist/chunk-OYZ64UMQ.js +67 -0
  179. package/dist/{chunk-UF4AZOZB.js → chunk-PB3NCPRF.js} +10 -8
  180. package/dist/chunk-PIPJZIJE.js +47 -0
  181. package/dist/{chunk-2RLKFUUL.js → chunk-PIPYJTIL.js} +27 -24
  182. package/dist/{chunk-MZCGSXVR.js → chunk-PUMNCWHJ.js} +15 -13
  183. package/dist/{chunk-X5F3Q5LV.js → chunk-PZBNDFZ7.js} +35 -25
  184. package/dist/chunk-Q2ULHBCJ.js +59 -0
  185. package/dist/{chunk-ZJFRMSJT.js → chunk-Q5QSWV2R.js} +14 -12
  186. package/dist/{chunk-Q2TECDIT.js → chunk-QFDPX6C4.js} +2886 -20703
  187. package/dist/{chunk-WG5U3F5V.js → chunk-QGBS4GMS.js} +14 -12
  188. package/dist/{chunk-BTGPE6CR.js → chunk-QIDSEHJA.js} +17 -15
  189. package/dist/{chunk-Q6DFNVRJ.js → chunk-QJ3AYXVO.js} +14 -12
  190. package/dist/{chunk-EBL2R3YG.js → chunk-QK6CGRKK.js} +6 -4
  191. package/dist/{chunk-S7FCV7S5.js → chunk-QOC3Q4UU.js} +1 -1
  192. package/dist/{chunk-JJF6HALY.js → chunk-QPLNB2BM.js} +5 -3
  193. package/dist/chunk-QVF4KYIO.js +71 -0
  194. package/dist/{chunk-6OJQOPUN.js → chunk-QXXEO4TF.js} +5 -3
  195. package/dist/{chunk-F3P7N7SF.js → chunk-QYFNVQLK.js} +1 -1
  196. package/dist/{chunk-6MUGR4LS.js → chunk-R6CJOMPC.js} +106 -29
  197. package/dist/{chunk-BDKC6H5P.js → chunk-ROWZYQOI.js} +9 -7
  198. package/dist/{chunk-2MMCFP5C.js → chunk-RQAMZVWW.js} +10 -8
  199. package/dist/chunk-RQSUFGU2.js +55 -0
  200. package/dist/{chunk-SDKLKB6I.js → chunk-RRKM3GJA.js} +38 -28
  201. package/dist/{chunk-OHNCWBKF.js → chunk-RSHVSXPJ.js} +7 -5
  202. package/dist/chunk-RSKMV3VC.js +22 -0
  203. package/dist/{chunk-U76OWS3Q.js → chunk-RU5W7JJQ.js} +25 -23
  204. package/dist/{chunk-63YRMR6J.js → chunk-RYY554OA.js} +7 -5
  205. package/dist/{chunk-5NMKONLP.js → chunk-SGYQORAD.js} +7 -3
  206. package/dist/{chunk-JA5FI3QV.js → chunk-SLGUSFOD.js} +3 -3
  207. package/dist/{chunk-M3NANSDZ.js → chunk-SUAHNYNQ.js} +17 -15
  208. package/dist/{chunk-QAXW2N3B.js → chunk-SUYC5NP6.js} +34 -34
  209. package/dist/{chunk-FFTRTL6R.js → chunk-SWSGRRNO.js} +6 -4
  210. package/dist/{chunk-UWOJLHFT.js → chunk-SYLXQNPC.js} +38 -24
  211. package/dist/chunk-T24TBI7F.js +54 -0
  212. package/dist/chunk-T2HXLDY3.js +55 -0
  213. package/dist/{chunk-O4GXGGBX.js → chunk-T5NH5L7A.js} +16 -13
  214. package/dist/{chunk-KXITGYLF.js → chunk-TAR6T2RE.js} +4 -2
  215. package/dist/chunk-TBQHBOFF.js +324 -0
  216. package/dist/{chunk-LKOR5UET.js → chunk-TKE6ZJMM.js} +26 -24
  217. package/dist/chunk-TKEXS74L.js +52 -0
  218. package/dist/{chunk-J3IOLXWM.js → chunk-TXYMNKGM.js} +16 -14
  219. package/dist/{chunk-IDKCWSM5.js → chunk-U2JTTRKS.js} +401 -115
  220. package/dist/{chunk-TNR75OXT.js → chunk-U37ZOYJJ.js} +11 -8
  221. package/dist/{chunk-7MJSQTL5.js → chunk-U57VLY6X.js} +23 -21
  222. package/dist/{chunk-BHT7QK4G.js → chunk-U66RQUFC.js} +6 -4
  223. package/dist/chunk-UCFNHK5L.js +50 -0
  224. package/dist/{chunk-IFKEI4SA.js → chunk-UI6KNLSO.js} +31 -11
  225. package/dist/{chunk-7GJS6DNX.js → chunk-UKRJ2ISN.js} +13 -3
  226. package/dist/chunk-UWJOM457.js +232 -0
  227. package/dist/{chunk-D73UEXYW.js → chunk-UXO25YBN.js} +3 -3
  228. package/dist/chunk-VE2T5URA.js +51 -0
  229. package/dist/{chunk-C3RY6KU6.js → chunk-W4EG25TI.js} +513 -172
  230. package/dist/{chunk-O66DM6DJ.js → chunk-WAAPMZWO.js} +6 -4
  231. package/dist/{chunk-R7NYHMUU.js → chunk-WECCLSYY.js} +4884 -3669
  232. package/dist/chunk-WQDJGNJQ.js +45 -0
  233. package/dist/{chunk-UWMJKX5U.js → chunk-WWSCJBF6.js} +14 -12
  234. package/dist/{chunk-N3XIYPU3.js → chunk-X7HFXXTZ.js} +16 -13
  235. package/dist/chunk-X7XVMYIL.js +5 -0
  236. package/dist/{chunk-NR2UJWOC.js → chunk-XERIHPBF.js} +12 -9
  237. package/dist/{chunk-JRBFANFE.js → chunk-XKNISZ6N.js} +21 -18
  238. package/dist/{chunk-PPD7HTDP.js → chunk-XNH5ZWIA.js} +20 -18
  239. package/dist/{chunk-7IOWA5D5.js → chunk-XNW3EDCY.js} +13 -3
  240. package/dist/{chunk-2LGRMVCA.js → chunk-XPXOKHNZ.js} +13 -11
  241. package/dist/{chunk-ZJXLNDH4.js → chunk-XXRBAJ36.js} +14 -12
  242. package/dist/{chunk-EHA7RMZ3.js → chunk-YA2IJJ6N.js} +8 -6
  243. package/dist/{chunk-LGBMTVNT.js → chunk-YB5AKYVQ.js} +7 -5
  244. package/dist/{chunk-JB5LINEM.js → chunk-YDDLVBQ4.js} +3 -3
  245. package/dist/{chunk-PAQ2AS5E.js → chunk-YF6N45QN.js} +1 -1
  246. package/dist/{chunk-WMTRHUI5.js → chunk-YHWX5LPT.js} +23 -21
  247. package/dist/{chunk-KQGURXFU.js → chunk-YLZNTVZR.js} +36 -13
  248. package/dist/{chunk-NY2XSR5K.js → chunk-YUJTOALL.js} +118 -18
  249. package/dist/{chunk-VZALIKIF.js → chunk-Z5YDTIWQ.js} +19 -16
  250. package/dist/{chunk-LDLL7LB3.js → chunk-ZCU2UY47.js} +24 -22
  251. package/dist/{chunk-OWNCM4ZN.js → chunk-ZIAYNHHE.js} +197 -17
  252. package/dist/{chunk-WJF2CS6M.js → chunk-ZJ2W2RDE.js} +7 -5
  253. package/dist/{chunk-REWWDVQB.js → chunk-ZRQHSMPK.js} +6 -4
  254. package/dist/{chunk-O7XLYEFA.js → chunk-ZSD75FYI.js} +57 -23
  255. package/dist/chunk-ZSNNF26J.js +220 -0
  256. package/dist/{chunk-BQ4SQQC6.js → chunk-ZX6RAGE6.js} +11 -9
  257. package/dist/files.json +583 -515
  258. package/dist/packages/sdk/npm/index.js +6428 -4882
  259. package/dist/packages/ui/dist/assets/{elk-api-CIf-0gz5.js → elk-api--rH6Kdl4.js} +2 -2
  260. package/dist/packages/ui/dist/assets/index-Bf2immpE.css +1 -0
  261. package/dist/packages/ui/dist/assets/index-CH4nGIW3.js +62 -0
  262. package/dist/packages/ui/dist/index.html +2 -2
  263. package/package.json +6 -6
  264. package/dist/chunk-2SKB4O2E.js +0 -59
  265. package/dist/chunk-4U276ICE.js +0 -39
  266. package/dist/chunk-6H3Z5JHH.js +0 -64
  267. package/dist/chunk-AFZ3QA6W.js +0 -47
  268. package/dist/chunk-AVTBS4OW.js +0 -49
  269. package/dist/chunk-C4R4JLHE.js +0 -40
  270. package/dist/chunk-CBGGOQWU.js +0 -82
  271. package/dist/chunk-CMDXGQTS.js +0 -47
  272. package/dist/chunk-DLOBCJL6.js +0 -48
  273. package/dist/chunk-GIW4ZVDB.js +0 -39
  274. package/dist/chunk-IP74LCOQ.js +0 -57
  275. package/dist/chunk-IPHHDDC6.js +0 -45
  276. package/dist/chunk-KJXD4PNL.js +0 -50
  277. package/dist/chunk-KN5BXMWN.js +0 -44
  278. package/dist/chunk-MFHL5URL.js +0 -31
  279. package/dist/chunk-NXJ5URP6.js +0 -51
  280. package/dist/chunk-OMI6FPPN.js +0 -43
  281. package/dist/chunk-ONUPY3H6.js +0 -53
  282. package/dist/chunk-OTLDSZDV.js +0 -69
  283. package/dist/chunk-PSOFBQWB.js +0 -42
  284. package/dist/chunk-T4YPZIQN.js +0 -36
  285. package/dist/chunk-TUULXQRW.js +0 -420
  286. package/dist/chunk-WNKPRSGI.js +0 -36
  287. package/dist/packages/ui/dist/assets/index-CoK_Dl0D.js +0 -47
  288. package/dist/packages/ui/dist/assets/index-Dw20IRhQ.css +0 -1
  289. package/dist/{chunk-24XLDU72.js → chunk-PXMV2LLY.js} +3 -3
@@ -6,11 +6,11 @@ var __atticusPath = (p) => __atticusFileURLToPath(__atticusUrl(p));
6
6
  import {
7
7
  boundedId,
8
8
  opt
9
- } from "./chunk-QKUJMING.js";
9
+ } from "./chunk-GFYVVTKH.js";
10
10
  import {
11
11
  curatedAliases,
12
12
  resolveNames
13
- } from "./chunk-6ZGLAACW.js";
13
+ } from "./chunk-DIYNRYXW.js";
14
14
  import {
15
15
  DATA_RULE,
16
16
  INSTRUCTION_RULES,
@@ -27,51 +27,55 @@ import {
27
27
  toRunSummary,
28
28
  verdictOf,
29
29
  wrapData
30
- } from "./chunk-P32RUW3B.js";
30
+ } from "./chunk-MOWUP33K.js";
31
31
  import {
32
- AgentDefinition,
33
- ChecklistPack,
34
- ChecklistRule,
35
- IsoDateTime,
36
32
  JOINED_BY_PERSON,
37
- KNOWLEDGE_KINDS,
38
- KNOWLEDGE_RECORD_KIND,
39
- PatternCode,
40
- Profile,
41
- RecordId,
42
- SOURCE_KIND_SUGGESTIONS,
43
- Sources,
44
- authorityRank,
45
33
  deserializeRecord,
46
34
  estimateTokens,
47
- external_exports,
48
- gitRefProblem,
49
35
  isAdopted,
50
- isAiBy,
51
36
  judgmentKey,
52
37
  knowledgeDirOf,
53
- knowledgeKindOf,
54
38
  knowledgeRelOf,
55
39
  listQuestions,
56
- loadOrgPack,
57
40
  makeJudgment,
58
41
  memoryJudgments,
59
42
  orgPackDirOf,
60
- pageStanding,
61
43
  parseRecord,
62
- platformsMatch,
63
44
  proposalsDirOf,
64
45
  proposalsRelOf,
65
46
  readParsedFiles,
66
47
  recordPath,
67
48
  serializeRecord,
68
- sourceReadsPage,
69
49
  toCanonicalYaml
70
- } from "./chunk-Q2TECDIT.js";
50
+ } from "./chunk-GJVCBTSO.js";
71
51
  import {
72
- SCHEMA_VERSION,
73
52
  writeFileAtomic
74
- } from "./chunk-TUULXQRW.js";
53
+ } from "./chunk-G3ZFEHCX.js";
54
+ import {
55
+ AgentDefinition,
56
+ ChecklistPack,
57
+ ChecklistRule,
58
+ IsoDateTime,
59
+ KNOWLEDGE_KINDS,
60
+ KNOWLEDGE_RECORD_KIND,
61
+ PatternCode,
62
+ Profile,
63
+ RecordId,
64
+ SOURCE_KIND_SUGGESTIONS,
65
+ Sources,
66
+ authorityRank,
67
+ external_exports,
68
+ gitRefProblem,
69
+ isAiBy,
70
+ knowledgeKindOf,
71
+ loadOrgPack,
72
+ pageStanding,
73
+ platformsMatch,
74
+ sourceReadsPage
75
+ } from "./chunk-QFDPX6C4.js";
76
+ import {
77
+ SCHEMA_VERSION
78
+ } from "./chunk-CTJHEG6A.js";
75
79
  import {
76
80
  require_dist
77
81
  } from "./chunk-BQGDB6ZL.js";
@@ -79,11 +83,6 @@ import {
79
83
  __toESM
80
84
  } from "./chunk-TV45EUGM.js";
81
85
 
82
- // packages/knowledge/dist/sources.js
83
- import { createHash as createHash2 } from "node:crypto";
84
- import { readdir as readdir2, readFile as readFile2 } from "node:fs/promises";
85
- import { isAbsolute as isAbsolute2, join as join3, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
86
-
87
86
  // packages/knowledge/dist/markdown.js
88
87
  var import_yaml = __toESM(require_dist(), 1);
89
88
  var HEADING = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/;
@@ -314,6 +313,11 @@ function mentionIndex(records, systems) {
314
313
  };
315
314
  }
316
315
 
316
+ // packages/knowledge/dist/sources.js
317
+ import { createHash as createHash2 } from "node:crypto";
318
+ import { readdir as readdir2, readFile as readFile2 } from "node:fs/promises";
319
+ import { isAbsolute as isAbsolute2, join as join3, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
320
+
317
321
  // packages/knowledge/dist/exports.js
318
322
  var import_yaml2 = __toESM(require_dist(), 1);
319
323
  import { readdir, readFile } from "node:fs/promises";
@@ -528,6 +532,25 @@ ${(0, import_yaml2.stringify)(fm, { lineWidth: 0 })}---
528
532
  ${body}`;
529
533
  }
530
534
  var titleSegment = (t) => t.normalize("NFKD").replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "") || "page";
535
+ function uniquePagePaths(pages, alt, keeps = () => false) {
536
+ const count = /* @__PURE__ */ new Map();
537
+ for (const p of pages)
538
+ count.set(p.pagePath, (count.get(p.pagePath) ?? 0) + 1);
539
+ const taken = new Set(pages.filter((p) => count.get(p.pagePath) === 1).map((p) => p.pagePath));
540
+ const out = [];
541
+ for (const p of pages) {
542
+ if (count.get(p.pagePath) === 1) {
543
+ out.push(p);
544
+ continue;
545
+ }
546
+ let path = keeps(p) && !taken.has(p.pagePath) ? p.pagePath : alt(p);
547
+ for (let n = 2; taken.has(path); n++)
548
+ path = alt(p).replace(/\.md$/, `-${n}.md`);
549
+ taken.add(path);
550
+ out.push({ ...p, pagePath: path });
551
+ }
552
+ return out;
553
+ }
531
554
  function readCsv(text2) {
532
555
  const rows = [];
533
556
  let row = [];
@@ -686,7 +709,11 @@ var confluenceExportAdapter = {
686
709
  ...m.updated ? { updatedAt: m.updated } : {}
687
710
  });
688
711
  }
689
- return out;
712
+ return uniquePagePaths(out, (p) => {
713
+ const file = p.path.split("/").pop().replace(/\.html?$/i, "");
714
+ const id = /(?:^|_)(\d+)$/.exec(file)?.[1] ?? titleSegment(file);
715
+ return p.pagePath.replace(/\.md$/, `-${id}.md`);
716
+ });
690
717
  }
691
718
  };
692
719
  var sharepointExportAdapter = {
@@ -726,7 +753,8 @@ var sharepointExportAdapter = {
726
753
  ...m.updated ? { updatedAt: m.updated } : {}
727
754
  });
728
755
  }
729
- return out;
756
+ const ext = (p) => /\.([^./]+)$/.exec(p.path)?.[1]?.toLowerCase() ?? "";
757
+ return uniquePagePaths(out, (p) => p.pagePath.replace(/\.md$/, `.${ext(p)}.md`), (p) => ext(p) === "md");
730
758
  }
731
759
  };
732
760
 
@@ -899,6 +927,53 @@ var markdownFolderAdapter = {
899
927
  return out;
900
928
  }
901
929
  };
930
+ function withApiMeta(body, labels, restricted) {
931
+ if (!labels?.length && !restricted)
932
+ return body;
933
+ const lines = body.replace(/\r\n?/g, "\n").split("\n");
934
+ const end = frontMatterEnd(lines);
935
+ let own = {};
936
+ let rest = body;
937
+ if (end > 0) {
938
+ const doc = readMarkdown(lines.slice(0, end + 1).join("\n"));
939
+ if (doc.frontMatterProblem)
940
+ return body;
941
+ own = doc.frontMatter;
942
+ rest = lines.slice(end + 1).join("\n");
943
+ }
944
+ const ownLabels = end > 0 && own.labels !== void 0 && own.labels !== null ? Array.isArray(own.labels) ? own.labels.map(String) : String(own.labels).split(/[;,]/).map((x) => x.trim()).filter(Boolean) : [];
945
+ const all = [...ownLabels, ...(labels ?? []).filter((l) => !ownLabels.includes(l))];
946
+ const fm = [
947
+ ...all.length ? [`labels: [${all.map((l) => JSON.stringify(l)).join(", ")}]`] : [],
948
+ ...restricted ? ["restricted: true"] : [],
949
+ ...Object.entries(own).filter(([k]) => k !== "labels" && !(restricted && k === "restricted")).map(([k, v]) => `${JSON.stringify(k)}: ${JSON.stringify(v ?? null)}`)
950
+ ];
951
+ return `---
952
+ ${fm.join("\n")}
953
+ ---
954
+ ${rest}`;
955
+ }
956
+ function wikiApiAdapter(api) {
957
+ return {
958
+ async pages(source) {
959
+ const out = [];
960
+ for (const space of source.spaces) {
961
+ const heads = await api.listPages(space);
962
+ for (const h of [...heads].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0)) {
963
+ const p = await api.getPage(h.id);
964
+ out.push({
965
+ pagePath: `${space}/${p.id}`,
966
+ path: `${source.id}:${space}/${p.id}`,
967
+ content: withApiMeta(p.body, p.labels, p.restricted),
968
+ updatedAt: p.updatedAt,
969
+ version: String(p.version)
970
+ });
971
+ }
972
+ }
973
+ return out;
974
+ }
975
+ };
976
+ }
902
977
  var DEFAULT_LEVELS = ["public", "internal", "confidential", "restricted"];
903
978
  var DAY = 864e5;
904
979
  var daysBetween = (from, to) => Math.floor((Date.parse(to) - Date.parse(from)) / DAY);
@@ -1049,11 +1124,36 @@ async function syncSources(o) {
1049
1124
  read.push({ source, raw: reads.filter((r) => !r.skipReason) });
1050
1125
  }
1051
1126
  const owners = pageOwners(read.filter((x) => !o.adaptersById?.[x.source.id]));
1127
+ const checked = /* @__PURE__ */ new Map();
1128
+ const checkedPage = (source, r) => {
1129
+ const key = `${source.id}\0${r.path}\0${r.pagePath}`;
1130
+ const known = checked.get(key);
1131
+ if (known)
1132
+ return known;
1133
+ const page = readPage({
1134
+ source: source.id,
1135
+ sourceType: source.type,
1136
+ path: r.path,
1137
+ pagePath: r.pagePath,
1138
+ content: r.content,
1139
+ ...r.updatedAt ? { updatedAt: r.updatedAt } : {},
1140
+ ...r.version ? { version: r.version } : {},
1141
+ records,
1142
+ systems,
1143
+ defaultClassification,
1144
+ mentions: index
1145
+ });
1146
+ const level = levels.indexOf(page.classification);
1147
+ const skip = page.doc.frontMatterProblem ? page.doc.frontMatterProblem : !source.readRestricted && pageRestricted(page.frontMatter) ? "under view restrictions, so above the limit for the metarepo's audience (readRestricted on the source says everyone who reads the metarepo may read it)" : level === -1 ? `unknown classification ${page.classification}` : level > limitLevel ? `${page.classification} is above the limit (${limit})` : void 0;
1148
+ const out = { page, ...skip !== void 0 ? { skip } : {} };
1149
+ checked.set(key, out);
1150
+ return out;
1151
+ };
1052
1152
  const mirrors = mirrorReaders(read.filter((x) => !o.adaptersById?.[x.source.id]).map((x) => ({
1053
1153
  source: x.source,
1054
1154
  raw: x.raw.filter((r) => {
1055
1155
  const owner = owners.get(r.path);
1056
- return !owner || owner.source === x.source.id;
1156
+ return (!owner || owner.source === x.source.id) && !checkedPage(x.source, r).skip;
1057
1157
  })
1058
1158
  })), o.orgPack);
1059
1159
  for (const { source, raw: all } of read) {
@@ -1078,38 +1178,9 @@ async function syncSources(o) {
1078
1178
  }
1079
1179
  const flagged = new Map(screenDocuments(raw.map((r) => ({ path: r.path, text: r.content, format: "markdown" }))).map((f) => [f.path, f]));
1080
1180
  for (const r of raw) {
1081
- const page = readPage({
1082
- source: source.id,
1083
- sourceType: source.type,
1084
- path: r.path,
1085
- pagePath: r.pagePath,
1086
- content: r.content,
1087
- ...r.updatedAt ? { updatedAt: r.updatedAt } : {},
1088
- ...r.version ? { version: r.version } : {},
1089
- records,
1090
- systems,
1091
- defaultClassification,
1092
- mentions: index
1093
- });
1094
- if (page.doc.frontMatterProblem) {
1095
- res.skipped.push({ source: source.id, path: r.path, reason: page.doc.frontMatterProblem });
1096
- continue;
1097
- }
1098
- if (!source.readRestricted && pageRestricted(page.frontMatter)) {
1099
- res.skipped.push({
1100
- source: source.id,
1101
- path: r.path,
1102
- reason: "under view restrictions, so above the limit for the metarepo's audience (readRestricted on the source says everyone who reads the metarepo may read it)"
1103
- });
1104
- continue;
1105
- }
1106
- const level = levels.indexOf(page.classification);
1107
- if (level === -1 || level > limitLevel) {
1108
- res.skipped.push({
1109
- source: source.id,
1110
- path: r.path,
1111
- reason: level === -1 ? `unknown classification ${page.classification}` : `${page.classification} is above the limit (${limit})`
1112
- });
1181
+ const { page, skip } = checkedPage(source, r);
1182
+ if (skip !== void 0) {
1183
+ res.skipped.push({ source: source.id, path: r.path, reason: skip });
1113
1184
  continue;
1114
1185
  }
1115
1186
  if (page.date) {
@@ -1138,8 +1209,41 @@ async function syncSources(o) {
1138
1209
  res.documents.push(sourceDocument(page));
1139
1210
  }
1140
1211
  }
1212
+ res.documents = uniqueDocumentIds(res.pages, res.documents);
1141
1213
  return res;
1142
1214
  }
1215
+ function uniqueDocumentIds(pages, docs) {
1216
+ const by = /* @__PURE__ */ new Map();
1217
+ docs.forEach((d, k) => by.set(d.id, [...by.get(d.id) ?? [], k]));
1218
+ const out = [...docs];
1219
+ const taken = new Set(docs.map((d) => d.id));
1220
+ const plain = (k) => {
1221
+ const base = pages[k].pagePath.replace(/\.(md|markdown)$/i, "");
1222
+ return slug(base) === base;
1223
+ };
1224
+ const byPath = (a, b) => {
1225
+ const x = pages[a].pagePath;
1226
+ const y = pages[b].pagePath;
1227
+ return x < y ? -1 : x > y ? 1 : 0;
1228
+ };
1229
+ for (const [id, ks] of by) {
1230
+ if (ks.length < 2)
1231
+ continue;
1232
+ const order = [...ks].sort((a, b) => Number(plain(b)) - Number(plain(a)) || byPath(a, b));
1233
+ for (const k of order.slice(1)) {
1234
+ const p = pages[k];
1235
+ const h = createHash2("sha256").update(`${p.source}\0${p.pagePath}`).digest("hex");
1236
+ const withHash = (n2) => `${id.slice(0, 119 - n2).replace(/[-.]+$/, "")}-${h.slice(0, n2)}`;
1237
+ let n = 8;
1238
+ while (taken.has(withHash(n)) && n < 32)
1239
+ n += 4;
1240
+ const next = withHash(n);
1241
+ taken.add(next);
1242
+ out[k] = { ...docs[k], id: next };
1243
+ }
1244
+ }
1245
+ return out;
1246
+ }
1143
1247
  function pageOwners(read) {
1144
1248
  const by = /* @__PURE__ */ new Map();
1145
1249
  for (const { source, raw } of read)
@@ -1955,11 +2059,6 @@ var FlowGraph = class {
1955
2059
  }
1956
2060
  };
1957
2061
 
1958
- // packages/features/dist/proposals.js
1959
- var import_yaml4 = __toESM(require_dist(), 1);
1960
- import { mkdir, readdir as readdir3, readFile as readFile3, writeFile } from "node:fs/promises";
1961
- import { join as join4 } from "node:path";
1962
-
1963
2062
  // packages/features/dist/detect.js
1964
2063
  var ENTRY_TYPES = /* @__PURE__ */ new Set(["rest", "grpc", "soap", "graphql", "webhook", "websocket", "sse"]);
1965
2064
  var DEFAULT_DEPTH = 8;
@@ -2402,6 +2501,9 @@ function detectFeatures(records, o = {}) {
2402
2501
  }
2403
2502
 
2404
2503
  // packages/features/dist/proposals.js
2504
+ var import_yaml4 = __toESM(require_dist(), 1);
2505
+ import { mkdir, readdir as readdir3, readFile as readFile3, writeFile } from "node:fs/promises";
2506
+ import { join as join4 } from "node:path";
2405
2507
  var NameProposalFile = external_exports.strictObject({
2406
2508
  schemaVersion: external_exports.literal(1),
2407
2509
  feature: RecordId,
@@ -3491,6 +3593,48 @@ function newestEvidence(r, commitDates = {}) {
3491
3593
  }
3492
3594
  return best;
3493
3595
  }
3596
+ function freshness(input) {
3597
+ const windows = input.orgPack?.pack?.freshness ?? {};
3598
+ const fallback = input.defaultDays ?? 365;
3599
+ const res = { stale: [], undated: [], documents: [] };
3600
+ const sorted2 = [...input.records].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
3601
+ for (const r of sorted2) {
3602
+ const maxDays = windows[r.kind] ?? fallback;
3603
+ if (r.kind === "SourceDocument") {
3604
+ if (r.supersededBy)
3605
+ res.documents.push({
3606
+ id: r.id,
3607
+ path: r.path,
3608
+ reason: "superseded",
3609
+ supersededBy: r.supersededBy
3610
+ });
3611
+ else if (r.date) {
3612
+ const ageDays2 = daysBetween(r.date, input.now);
3613
+ if (ageDays2 > maxDays)
3614
+ res.documents.push({
3615
+ id: r.id,
3616
+ path: r.path,
3617
+ reason: "stale",
3618
+ date: r.date,
3619
+ ageDays: ageDays2,
3620
+ maxDays
3621
+ });
3622
+ }
3623
+ continue;
3624
+ }
3625
+ if (r.kind === "CuratedDecision")
3626
+ continue;
3627
+ const newest = newestEvidence(r, input.commitDates);
3628
+ if (!newest) {
3629
+ res.undated.push(r.id);
3630
+ continue;
3631
+ }
3632
+ const ageDays = daysBetween(newest, input.now);
3633
+ if (ageDays > maxDays)
3634
+ res.stale.push({ id: r.id, kind: r.kind, newest, ageDays, maxDays });
3635
+ }
3636
+ return res;
3637
+ }
3494
3638
 
3495
3639
  // packages/knowledge/dist/gaps.js
3496
3640
  function governingPatterns(i, ctx) {
@@ -4160,6 +4304,150 @@ function domainProfile(records, system, o) {
4160
4304
  return (o.template ?? DEFAULT_DOMAIN_PROFILE).replace(/\{\{\s*([a-z]+)\s*\}\}/g, (whole, k) => values[k] ?? whole);
4161
4305
  }
4162
4306
 
4307
+ // packages/knowledge/dist/quotes.js
4308
+ var HEADING2 = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/;
4309
+ var FENCE2 = /^ {0,3}(```+|~~~+)/;
4310
+ var SETEXT = /^ {0,3}(?:=+|-+)\s*$/;
4311
+ function visibleText(text2) {
4312
+ const spans = hiddenSpans(text2);
4313
+ if (!spans.length)
4314
+ return text2;
4315
+ let out = "";
4316
+ let at = 0;
4317
+ for (const s2 of spans) {
4318
+ if (s2.start < at)
4319
+ continue;
4320
+ out += text2.slice(at, s2.start) + text2.slice(s2.start, s2.end).replace(/[^\n]/g, " ");
4321
+ at = s2.end;
4322
+ }
4323
+ return out + text2.slice(at);
4324
+ }
4325
+ function pageLines(text2) {
4326
+ const lines = visibleText(text2.replace(/\r\n?/g, "\n")).split("\n");
4327
+ let i = 0;
4328
+ if (lines[0]?.trim() === "---") {
4329
+ const end = lines.findIndex((l, k) => k > 0 && (l.trim() === "---" || l.trim() === "..."));
4330
+ if (end > 0)
4331
+ i = end + 1;
4332
+ }
4333
+ const out = [];
4334
+ let section = "";
4335
+ let fence;
4336
+ for (; i < lines.length; i++) {
4337
+ const l = lines[i];
4338
+ const f = FENCE2.exec(l);
4339
+ if (f)
4340
+ fence = fence ? l.trim().startsWith(fence) ? void 0 : fence : f[1];
4341
+ const h = fence ? void 0 : HEADING2.exec(l);
4342
+ if (h) {
4343
+ section = h[2];
4344
+ continue;
4345
+ }
4346
+ const next = lines[i + 1];
4347
+ if (!fence && !f && l.trim() && next !== void 0 && SETEXT.test(next) && !SETEXT.test(l)) {
4348
+ section = l.trim();
4349
+ i++;
4350
+ continue;
4351
+ }
4352
+ out.push({ line: i + 1, text: l, section });
4353
+ }
4354
+ return out;
4355
+ }
4356
+ var foldQuote = (s2) => s2.replace(/[‘’‛′]/g, "'").replace(/[“”‟″]/g, '"').replace(/\s+/g, " ").trim();
4357
+ var ENTITIES2 = {
4358
+ amp: "&",
4359
+ lt: "<",
4360
+ gt: ">",
4361
+ quot: '"',
4362
+ apos: "'",
4363
+ nbsp: " ",
4364
+ ndash: "\u2013",
4365
+ mdash: "\u2014",
4366
+ hellip: "\u2026",
4367
+ lsquo: "\u2018",
4368
+ rsquo: "\u2019",
4369
+ ldquo: "\u201C",
4370
+ rdquo: "\u201D",
4371
+ zwsp: "",
4372
+ shy: ""
4373
+ };
4374
+ var INLINE_TAG = /<\/?(?:a|abbr|b|bdi|big|cite|code|del|dfn|em|font|i|ins|kbd|mark|q|s|samp|small|span|strike|strong|sub|sup|time|tt|u|var)(?:\s[^<>]*)?\/?>/gi;
4375
+ var ALNUM = /[\p{L}\p{N}]/u;
4376
+ function readerText(s2) {
4377
+ return s2.replace(/&(#x[0-9a-f]{1,6}|#[0-9]{1,7}|[a-z]{2,8});/gi, (m, e) => {
4378
+ if (e[0] !== "#")
4379
+ return ENTITIES2[e.toLowerCase()] ?? m;
4380
+ const n = e[1] === "x" || e[1] === "X" ? parseInt(e.slice(2), 16) : Number(e.slice(1));
4381
+ return n > 0 && n <= 1114111 ? String.fromCodePoint(n) : m;
4382
+ }).replace(/[\u200b-\u200d\u2060\ufeff\u00ad]/g, "").replace(/<br\s*\/?>/gi, " ").replace(INLINE_TAG, "").replace(/!?\[([^\]]*)\]\([^)\s]*(?:\s+"[^"]*")?\)/g, "$1").replace(/!?\[([^\]]+)\]\[[^\]]*\]/g, "$1").replace(/<((?:https?|mailto):[^<>\s]+)>/g, "$1").replace(/\\([!-/:-@[-`{-~])/g, "$1").replace(/`+/g, "").replace(/(^|[^\p{L}\p{N}*_~])(?:\*{1,3}|_{1,3}|~~)(?=[^\s*_~])/gu, "$1").replace(/([^\s*_~])(?:\*{1,3}|_{1,3}|~~)(?=$|[^\p{L}\p{N}*_~])/gu, "$1").replace(/([\p{L}\p{N}])\*{1,3}(?=[\p{L}\p{N}])/gu, "$1").replace(/[\u2010-\u2015\u2212]/g, "-").replace(/\u2026/g, "...");
4383
+ }
4384
+ var sameHeading = (a, b) => foldQuote(readerText(a)).replace(/^#+\s*/, "").toLowerCase() === foldQuote(readerText(b)).replace(/^#+\s*/, "").toLowerCase();
4385
+ var matchFold = (s2) => foldQuote(readerText(s2)).replace(/"/g, "'");
4386
+ var MARKERS = /^\s*(?:>\s?)*\s*(?:(?:[-*+]|\d{1,9}[.)])\s+)?/;
4387
+ var unmark = (s2) => s2.replace(MARKERS, "");
4388
+ function findIn(lines, q) {
4389
+ let text2 = "";
4390
+ const lineAt = [];
4391
+ for (const l of lines) {
4392
+ const t = matchFold(unmark(l.text));
4393
+ if (!t)
4394
+ continue;
4395
+ if (text2) {
4396
+ text2 += " ";
4397
+ lineAt.push(l.line);
4398
+ }
4399
+ for (let k = 0; k < t.length; k++)
4400
+ lineAt.push(l.line);
4401
+ text2 += t;
4402
+ }
4403
+ const wordStart = ALNUM.test(q[0] ?? "");
4404
+ const wordEnd = ALNUM.test(q.at(-1) ?? "");
4405
+ for (let at = text2.indexOf(q); at !== -1; at = text2.indexOf(q, at + 1)) {
4406
+ if (wordStart && at > 0 && ALNUM.test(text2[at - 1]))
4407
+ continue;
4408
+ const end = at + q.length;
4409
+ if (wordEnd && end < text2.length && ALNUM.test(text2[end]))
4410
+ continue;
4411
+ return lineAt[at];
4412
+ }
4413
+ return void 0;
4414
+ }
4415
+ function checkQuote(text2, quote2, section) {
4416
+ const q = matchFold(unmark(quote2)).replace(/[\s.,;:!?]+$/, "");
4417
+ if (q.length < 12)
4418
+ return { ok: false, problem: "the quote is too short to check" };
4419
+ const lines = pageLines(text2);
4420
+ const sections = [...new Set(lines.map((l) => l.section))];
4421
+ if (section !== void 0 && section.trim() !== "") {
4422
+ const wanted = sections.filter((s2) => sameHeading(s2, section));
4423
+ for (const s2 of wanted) {
4424
+ const line = findIn(lines.filter((l) => l.section === s2), q);
4425
+ if (line !== void 0)
4426
+ return { ok: true, line, section: s2 };
4427
+ }
4428
+ for (const s2 of sections) {
4429
+ const line = findIn(lines.filter((l) => l.section === s2), q);
4430
+ if (line !== void 0)
4431
+ return {
4432
+ ok: false,
4433
+ problem: wanted.length ? `the quote is on the page under "${s2 || "(no heading)"}", not under "${section}"` : `the page has no heading "${section}"; the quote is under "${s2 || "(no heading)"}"`,
4434
+ foundUnder: s2,
4435
+ line
4436
+ };
4437
+ }
4438
+ return {
4439
+ ok: false,
4440
+ problem: wanted.length ? `the quote is not on the page, word for word` : `the page has no heading "${section}", and the quote is not on the page, word for word`
4441
+ };
4442
+ }
4443
+ for (const s2 of sections) {
4444
+ const line = findIn(lines.filter((l) => l.section === s2), q);
4445
+ if (line !== void 0)
4446
+ return { ok: true, line, section: s2 };
4447
+ }
4448
+ return { ok: false, problem: "the quote is not on the page, word for word" };
4449
+ }
4450
+
4163
4451
  // packages/knowledge/dist/grounding.js
4164
4452
  var UNITS = {
4165
4453
  zero: 0,
@@ -4354,13 +4642,109 @@ function workingDays(d) {
4354
4642
  return Math.ceil(d.unit === "working-days" ? n : d.unit === "calendar-days" ? n * 5 / 7 : n / 8);
4355
4643
  }
4356
4644
 
4357
- // packages/knowledge/dist/tags.js
4358
- var import_yaml6 = __toESM(require_dist(), 1);
4359
- var slug3 = (s2) => s2.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
4360
- function tagList(values) {
4361
- return [
4362
- ...new Set(values.flatMap((v) => v.split(",")).map(slug3).filter(Boolean))
4363
- ];
4645
+ // packages/knowledge/dist/value-claims.js
4646
+ var LEAD_TIME = "lead-time";
4647
+ var leadTimeInputs = (item, leadTime) => ({
4648
+ v: 1,
4649
+ item,
4650
+ leadTime: leadTime.trim()
4651
+ });
4652
+ async function leadTimeDaysOf(store, item, leadTime) {
4653
+ if (!leadTime?.trim())
4654
+ return void 0;
4655
+ const j = await store.get(LEAD_TIME, judgmentKey(LEAD_TIME, leadTimeInputs(item, leadTime)));
4656
+ const v = j?.value;
4657
+ return v && typeof v.min === "number" && typeof v.max === "number" && v.unit ? { min: v.min, max: v.max, unit: v.unit } : void 0;
4658
+ }
4659
+ var VALUES = (field) => field === "lead_time" || field.startsWith("dates.");
4660
+ var inputsOf = (id, c) => ({
4661
+ v: 1,
4662
+ item: id,
4663
+ field: c.field,
4664
+ value: c.value,
4665
+ span: c.span
4666
+ });
4667
+ async function settleClaims(items, o) {
4668
+ const at = o.now.toISOString().replace(/\.\d{3}Z$/, "Z");
4669
+ const judging = o.runtime.kind !== "hand-off" && o.runtime.kind !== "mock";
4670
+ const out = /* @__PURE__ */ new Map();
4671
+ const fail = (id, p) => out.set(id, [...out.get(id) ?? [], p]);
4672
+ const verdicts = /* @__PURE__ */ new Map();
4673
+ const ask = [];
4674
+ for (const c of items)
4675
+ for (const cl of c.claims) {
4676
+ const inputs = inputsOf(c.item.id, cl);
4677
+ const key = judgmentKey(STATES_VALUE_SPEC.kind, inputs);
4678
+ const stored = await o.store.get(STATES_VALUE_SPEC.kind, key);
4679
+ if (stored && typeof stored.verdict === "string") {
4680
+ verdicts.set(key, { verdict: stored.verdict, by: stored.confirmedBy });
4681
+ continue;
4682
+ }
4683
+ if (judging)
4684
+ ask.push({
4685
+ inputs,
4686
+ texts: { span: cl.span },
4687
+ facts: [`field: ${cl.field}`, `value: ${cl.value}`]
4688
+ });
4689
+ else if (!VALUES(cl.field)) {
4690
+ const by = { by: "ai", run: o.run };
4691
+ await o.store.put(makeJudgment({
4692
+ kind: STATES_VALUE_SPEC.kind,
4693
+ inputs,
4694
+ verdict: "yes",
4695
+ quotes: [{ of: "span", text: cl.span }],
4696
+ why: "The reading the knowledge scan gave with the words it cited.",
4697
+ confirmedBy: by,
4698
+ at
4699
+ }));
4700
+ verdicts.set(key, { verdict: "yes", by });
4701
+ }
4702
+ }
4703
+ if (ask.length) {
4704
+ const r = await judge(STATES_VALUE_SPEC, ask, {
4705
+ runtime: o.runtime,
4706
+ store: o.store,
4707
+ change: "knowledge-scan",
4708
+ now: o.now
4709
+ });
4710
+ for (const [k, v] of r.results)
4711
+ verdicts.set(k, {
4712
+ verdict: v.verdict,
4713
+ by: v.judgment?.confirmedBy ?? { by: "check", rule: "veto" }
4714
+ });
4715
+ }
4716
+ for (const c of items) {
4717
+ let daysBy;
4718
+ for (const cl of c.claims) {
4719
+ const v = verdicts.get(judgmentKey(STATES_VALUE_SPEC.kind, inputsOf(c.item.id, cl)));
4720
+ if (v?.verdict === "yes") {
4721
+ if (cl.field === "lead_time_days")
4722
+ daysBy = v.by;
4723
+ continue;
4724
+ }
4725
+ fail(c.item.id, v === void 0 ? `${cl.field} "${cl.value}" isn't word for word in "${cl.span}": write it as the page says it` : `${cl.field} "${cl.value}": the words "${cl.span}" don't state it (a judge read them${v.verdict === "unsure" ? " and couldn't tell" : ""}); quote the words that do`);
4726
+ }
4727
+ const days = c.item.lead_time_days;
4728
+ if (days && daysBy && c.item.lead_time && !out.has(c.item.id))
4729
+ await o.store.put(makeJudgment({
4730
+ kind: LEAD_TIME,
4731
+ inputs: leadTimeInputs(c.item.id, c.item.lead_time),
4732
+ verdict: "normalised",
4733
+ value: days,
4734
+ confirmedBy: daysBy,
4735
+ at
4736
+ }));
4737
+ }
4738
+ return out;
4739
+ }
4740
+
4741
+ // packages/knowledge/dist/tags.js
4742
+ var import_yaml6 = __toESM(require_dist(), 1);
4743
+ var slug3 = (s2) => s2.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
4744
+ function tagList(values) {
4745
+ return [
4746
+ ...new Set(values.flatMap((v) => v.split(",")).map(slug3).filter(Boolean))
4747
+ ];
4364
4748
  }
4365
4749
  function setSourceTags(text2, sourceId, change) {
4366
4750
  const doc = (0, import_yaml6.parseDocument)(text2);
@@ -4487,8 +4871,19 @@ async function writeSnapshots(o) {
4487
4871
  pages: [],
4488
4872
  skipped: o.sync.skipped.filter((s2) => s2.source === w.id).map((s2) => ({ page: s2.path, reason: s2.reason }))
4489
4873
  };
4874
+ const listed = /* @__PURE__ */ new Map();
4490
4875
  for (const p of pages) {
4491
4876
  const file = safe(fileFor(p.pagePath));
4877
+ const first = listed.get(p.pagePath) ?? listed.get(`\0${file}`);
4878
+ if (first !== void 0) {
4879
+ manifest.skipped.push({
4880
+ page: p.path,
4881
+ reason: `another page of the source has the path ${p.pagePath} (${first}), which is kept`
4882
+ });
4883
+ continue;
4884
+ }
4885
+ listed.set(p.pagePath, p.path);
4886
+ listed.set(`\0${file}`, p.path);
4492
4887
  const was = before.get(p.pagePath);
4493
4888
  const keep = was && was.sha256 === p.hash && was.file === file ? was.in : void 0;
4494
4889
  if (!keep) {
@@ -4506,7 +4901,7 @@ async function writeSnapshots(o) {
4506
4901
  });
4507
4902
  }
4508
4903
  await writeFileAtomic(join5(dir, SNAPSHOT_FILE), (0, import_yaml7.stringify)(manifest));
4509
- out.push({ source: w.id, dir: rel, pages: pages.length, copied });
4904
+ out.push({ source: w.id, dir: rel, pages: manifest.pages.length, copied });
4510
4905
  }
4511
4906
  return out;
4512
4907
  }
@@ -4657,203 +5052,6 @@ function sectionAt(text2, line) {
4657
5052
  return lines.slice(start, end).join("\n");
4658
5053
  }
4659
5054
 
4660
- // packages/knowledge/dist/quotes.js
4661
- var HEADING2 = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/;
4662
- var FENCE2 = /^ {0,3}(```+|~~~+)/;
4663
- function visibleText(text2) {
4664
- const spans = hiddenSpans(text2);
4665
- if (!spans.length)
4666
- return text2;
4667
- let out = "";
4668
- let at = 0;
4669
- for (const s2 of spans) {
4670
- if (s2.start < at)
4671
- continue;
4672
- out += text2.slice(at, s2.start) + text2.slice(s2.start, s2.end).replace(/[^\n]/g, " ");
4673
- at = s2.end;
4674
- }
4675
- return out + text2.slice(at);
4676
- }
4677
- function pageLines(text2) {
4678
- const lines = visibleText(text2.replace(/\r\n?/g, "\n")).split("\n");
4679
- let i = 0;
4680
- if (lines[0]?.trim() === "---") {
4681
- const end = lines.findIndex((l, k) => k > 0 && (l.trim() === "---" || l.trim() === "..."));
4682
- if (end > 0)
4683
- i = end + 1;
4684
- }
4685
- const out = [];
4686
- let section = "";
4687
- let fence;
4688
- for (; i < lines.length; i++) {
4689
- const l = lines[i];
4690
- const f = FENCE2.exec(l);
4691
- if (f)
4692
- fence = fence ? l.trim().startsWith(fence) ? void 0 : fence : f[1];
4693
- const h = fence ? void 0 : HEADING2.exec(l);
4694
- if (h) {
4695
- section = h[2];
4696
- continue;
4697
- }
4698
- out.push({ line: i + 1, text: l, section });
4699
- }
4700
- return out;
4701
- }
4702
- var foldQuote = (s2) => s2.replace(/[‘’‛′]/g, "'").replace(/[“”‟″]/g, '"').replace(/\s+/g, " ").trim();
4703
- var sameHeading = (a, b) => foldQuote(a).replace(/^#+\s*/, "").toLowerCase() === foldQuote(b).replace(/^#+\s*/, "").toLowerCase();
4704
- var matchFold = (s2) => foldQuote(s2).replace(/"/g, "'");
4705
- var MARKERS = /^\s*(?:>\s?)*\s*(?:(?:[-*+]|\d{1,9}[.)])\s+)?/;
4706
- var unmark = (s2) => s2.replace(MARKERS, "");
4707
- function findIn(lines, q) {
4708
- let text2 = "";
4709
- const lineAt = [];
4710
- for (const l of lines) {
4711
- const t = matchFold(unmark(l.text));
4712
- if (!t)
4713
- continue;
4714
- if (text2) {
4715
- text2 += " ";
4716
- lineAt.push(l.line);
4717
- }
4718
- for (let k = 0; k < t.length; k++)
4719
- lineAt.push(l.line);
4720
- text2 += t;
4721
- }
4722
- const at = text2.indexOf(q);
4723
- return at === -1 ? void 0 : lineAt[at];
4724
- }
4725
- function checkQuote(text2, quote2, section) {
4726
- const q = matchFold(unmark(quote2)).replace(/[\s.,;:!?]+$/, "");
4727
- if (q.length < 12)
4728
- return { ok: false, problem: "the quote is too short to check" };
4729
- const lines = pageLines(text2);
4730
- const sections = [...new Set(lines.map((l) => l.section))];
4731
- if (section !== void 0 && section.trim() !== "") {
4732
- const wanted = sections.filter((s2) => sameHeading(s2, section));
4733
- for (const s2 of wanted) {
4734
- const line = findIn(lines.filter((l) => l.section === s2), q);
4735
- if (line !== void 0)
4736
- return { ok: true, line, section: s2 };
4737
- }
4738
- for (const s2 of sections) {
4739
- const line = findIn(lines.filter((l) => l.section === s2), q);
4740
- if (line !== void 0)
4741
- return {
4742
- ok: false,
4743
- problem: wanted.length ? `the quote is on the page under "${s2 || "(no heading)"}", not under "${section}"` : `the page has no heading "${section}"; the quote is under "${s2 || "(no heading)"}"`,
4744
- foundUnder: s2,
4745
- line
4746
- };
4747
- }
4748
- return {
4749
- ok: false,
4750
- problem: wanted.length ? `the quote is not on the page, word for word` : `the page has no heading "${section}", and the quote is not on the page, word for word`
4751
- };
4752
- }
4753
- for (const s2 of sections) {
4754
- const line = findIn(lines.filter((l) => l.section === s2), q);
4755
- if (line !== void 0)
4756
- return { ok: true, line, section: s2 };
4757
- }
4758
- return { ok: false, problem: "the quote is not on the page, word for word" };
4759
- }
4760
-
4761
- // packages/knowledge/dist/value-claims.js
4762
- var LEAD_TIME = "lead-time";
4763
- var leadTimeInputs = (item, leadTime) => ({
4764
- v: 1,
4765
- item,
4766
- leadTime: leadTime.trim()
4767
- });
4768
- async function leadTimeDaysOf(store, item, leadTime) {
4769
- if (!leadTime?.trim())
4770
- return void 0;
4771
- const j = await store.get(LEAD_TIME, judgmentKey(LEAD_TIME, leadTimeInputs(item, leadTime)));
4772
- const v = j?.value;
4773
- return v && typeof v.min === "number" && typeof v.max === "number" && v.unit ? { min: v.min, max: v.max, unit: v.unit } : void 0;
4774
- }
4775
- var VALUES = (field) => field === "lead_time" || field.startsWith("dates.");
4776
- var inputsOf = (id, c) => ({
4777
- v: 1,
4778
- item: id,
4779
- field: c.field,
4780
- value: c.value,
4781
- span: c.span
4782
- });
4783
- async function settleClaims(items, o) {
4784
- const at = o.now.toISOString().replace(/\.\d{3}Z$/, "Z");
4785
- const judging = o.runtime.kind !== "hand-off" && o.runtime.kind !== "mock";
4786
- const out = /* @__PURE__ */ new Map();
4787
- const fail = (id, p) => out.set(id, [...out.get(id) ?? [], p]);
4788
- const verdicts = /* @__PURE__ */ new Map();
4789
- const ask = [];
4790
- for (const c of items)
4791
- for (const cl of c.claims) {
4792
- const inputs = inputsOf(c.item.id, cl);
4793
- const key = judgmentKey(STATES_VALUE_SPEC.kind, inputs);
4794
- const stored = await o.store.get(STATES_VALUE_SPEC.kind, key);
4795
- if (stored && typeof stored.verdict === "string") {
4796
- verdicts.set(key, { verdict: stored.verdict, by: stored.confirmedBy });
4797
- continue;
4798
- }
4799
- if (judging)
4800
- ask.push({
4801
- inputs,
4802
- texts: { span: cl.span },
4803
- facts: [`field: ${cl.field}`, `value: ${cl.value}`]
4804
- });
4805
- else if (!VALUES(cl.field)) {
4806
- const by = { by: "ai", run: o.run };
4807
- await o.store.put(makeJudgment({
4808
- kind: STATES_VALUE_SPEC.kind,
4809
- inputs,
4810
- verdict: "yes",
4811
- quotes: [{ of: "span", text: cl.span }],
4812
- why: "The reading the knowledge scan gave with the words it cited.",
4813
- confirmedBy: by,
4814
- at
4815
- }));
4816
- verdicts.set(key, { verdict: "yes", by });
4817
- }
4818
- }
4819
- if (ask.length) {
4820
- const r = await judge(STATES_VALUE_SPEC, ask, {
4821
- runtime: o.runtime,
4822
- store: o.store,
4823
- change: "knowledge-scan",
4824
- now: o.now
4825
- });
4826
- for (const [k, v] of r.results)
4827
- verdicts.set(k, {
4828
- verdict: v.verdict,
4829
- by: v.judgment?.confirmedBy ?? { by: "check", rule: "veto" }
4830
- });
4831
- }
4832
- for (const c of items) {
4833
- let daysBy;
4834
- for (const cl of c.claims) {
4835
- const v = verdicts.get(judgmentKey(STATES_VALUE_SPEC.kind, inputsOf(c.item.id, cl)));
4836
- if (v?.verdict === "yes") {
4837
- if (cl.field === "lead_time_days")
4838
- daysBy = v.by;
4839
- continue;
4840
- }
4841
- fail(c.item.id, v === void 0 ? `${cl.field} "${cl.value}" isn't word for word in "${cl.span}": write it as the page says it` : `${cl.field} "${cl.value}": the words "${cl.span}" don't state it (a judge read them${v.verdict === "unsure" ? " and couldn't tell" : ""}); quote the words that do`);
4842
- }
4843
- const days = c.item.lead_time_days;
4844
- if (days && daysBy && c.item.lead_time && !out.has(c.item.id))
4845
- await o.store.put(makeJudgment({
4846
- kind: LEAD_TIME,
4847
- inputs: leadTimeInputs(c.item.id, c.item.lead_time),
4848
- verdict: "normalised",
4849
- value: days,
4850
- confirmedBy: daysBy,
4851
- at
4852
- }));
4853
- }
4854
- return out;
4855
- }
4856
-
4857
5055
  // packages/knowledge/dist/conflict-owner.js
4858
5056
  var dateOnly2 = (v) => {
4859
5057
  if (v instanceof Date)
@@ -5448,39 +5646,52 @@ function checkConflict(raw, pages, ids) {
5448
5646
  }
5449
5647
  };
5450
5648
  }
5451
- function checkSuperseded(raw, pages) {
5649
+ function resolveAnyPage(pages, snapshots, ref3) {
5650
+ const read = resolvePage(pages, ref3);
5651
+ if (read)
5652
+ return { source: read.page.source, page: read.page.pagePath };
5653
+ const r = ref3.trim().replace(/^\.\//, "");
5654
+ const all = snapshots.flatMap((s2) => s2.manifest.pages.map((p) => ({ source: s2.manifest.source, page: p.page })));
5655
+ const exact = all.find((p) => p.page === r || `${p.source}/${p.page}` === r);
5656
+ if (exact)
5657
+ return exact;
5658
+ const byName = all.filter((p) => basename(p.page) === basename(r));
5659
+ return byName.length === 1 ? byName[0] : void 0;
5660
+ }
5661
+ function checkSuperseded(raw, pages, snapshots) {
5452
5662
  const p = SupersededIn.safeParse(raw);
5453
5663
  if (!p.success)
5454
5664
  return { problem: `a superseded page: ${fmt(p.error.issues).join("; ")}` };
5455
5665
  const s2 = p.data;
5456
5666
  const oldP = resolvePage(pages, s2.old);
5457
- const newP = resolvePage(pages, s2.new);
5667
+ const newRef = resolveAnyPage(pages, snapshots, s2.new);
5458
5668
  if (!oldP)
5459
5669
  return { problem: `superseded: there is no page ${s2.old} in the snapshot` };
5460
- if (!newP)
5670
+ if (!newRef)
5461
5671
  return { problem: `superseded: there is no page ${s2.new} in the snapshot` };
5672
+ const newP = pages.find((x) => x.page.source === newRef.source && x.page.pagePath === newRef.page);
5462
5673
  const on = s2.page ? resolvePage(pages, s2.page, s2.quote) : void 0;
5463
- const candidates = on ? [on] : [newP, oldP];
5674
+ const candidates = on ? [on] : newP ? [newP, oldP] : [oldP];
5464
5675
  const where = candidates.find((c) => checkQuote(c.page.text ?? "", s2.quote).ok);
5465
5676
  if (!where)
5466
5677
  return {
5467
5678
  problem: `superseded ${s2.old}: the quote is not on ${candidates.map((c) => c.page.pagePath).join(" or ")}, word for word`
5468
5679
  };
5469
5680
  const ref3 = (x) => ({ source: x.page.source, page: x.page.pagePath });
5470
- return { ok: { old: ref3(oldP), new: ref3(newP), quote: s2.quote, quotedOn: ref3(where) } };
5681
+ return { ok: { old: ref3(oldP), new: newRef, quote: s2.quote, quotedOn: ref3(where) } };
5471
5682
  }
5472
- function frontMatterSuperseded(pages) {
5683
+ function frontMatterSuperseded(pages, snapshots) {
5473
5684
  const out = [];
5474
5685
  for (const p of pages) {
5475
5686
  const fm = p.page.frontMatter;
5476
5687
  const by = fm["superseded-by"] ?? fm.superseded_by ?? fm.supersededBy;
5477
5688
  if (typeof by !== "string")
5478
5689
  continue;
5479
- const n = resolvePage(pages, by) ?? resolvePage(pages, `${by}.md`);
5690
+ const n = resolveAnyPage(pages, snapshots, by) ?? resolveAnyPage(pages, snapshots, `${by}.md`);
5480
5691
  if (!n)
5481
5692
  continue;
5482
5693
  const ref3 = (x) => ({ source: x.page.source, page: x.page.pagePath });
5483
- out.push({ old: ref3(p), new: ref3(n), quote: `superseded-by: ${by}`, quotedOn: ref3(p) });
5694
+ out.push({ old: ref3(p), new: n, quote: `superseded-by: ${by}`, quotedOn: ref3(p) });
5484
5695
  }
5485
5696
  return out;
5486
5697
  }
@@ -5509,6 +5720,35 @@ function checkInjection(raw, pages) {
5509
5720
  };
5510
5721
  }
5511
5722
  var norm = (s2) => words4(s2).join(" ");
5723
+ var recordTitle = (r) => r.kind === "Pattern" || r.kind === "Party" || r.kind === "Product" ? r.name : r.title;
5724
+ function recordConflict(x, y) {
5725
+ if (x.kind !== y.kind || !x.quote || !y.quote)
5726
+ return void 0;
5727
+ if (x.quote.source === y.quote.source && x.quote.page === y.quote.page)
5728
+ return void 0;
5729
+ const field = (r, f) => {
5730
+ const v = r[f];
5731
+ return typeof v === "string" ? v : void 0;
5732
+ };
5733
+ const cx = field(x, "catalogueItem");
5734
+ const sameThing = norm(recordTitle(x)) === norm(recordTitle(y)) || !!cx && norm(cx) === norm(field(y, "catalogueItem") ?? "");
5735
+ if (!sameThing)
5736
+ return void 0;
5737
+ const differ = (f) => {
5738
+ const a = field(x, f);
5739
+ const b = field(y, f);
5740
+ return a !== void 0 && b !== void 0 && norm(a) !== norm(b);
5741
+ };
5742
+ if (!differ("leadTime") && !differ("handledBy"))
5743
+ return void 0;
5744
+ return {
5745
+ about: [x.id, y.id],
5746
+ pages: [x, y].map((i) => ({ source: i.quote.source, page: i.quote.page })),
5747
+ says: [x.quote.text, y.quote.text],
5748
+ summary: `${recordTitle(x)}: the pages disagree on ${differ("leadTime") ? "the lead time" : "who handles it"}`,
5749
+ foundBy: "check"
5750
+ };
5751
+ }
5512
5752
  function checkConflicts(items) {
5513
5753
  const out = [];
5514
5754
  for (let a = 0; a < items.length; a++)
@@ -5783,9 +6023,10 @@ async function scanKnowledge(snapshots, o) {
5783
6023
  return result;
5784
6024
  }
5785
6025
  const kept = /* @__PURE__ */ new Map();
6026
+ const takenBy = new Map((o.taken ?? []).map((r) => [r.id, r]));
5786
6027
  let failed = [];
5787
6028
  let conflicts = [];
5788
- const superseded = frontMatterSuperseded(pages);
6029
+ const superseded = frontMatterSuperseded(pages, snapshots);
5789
6030
  const aiInjections = [];
5790
6031
  let feedback = [];
5791
6032
  let answered2 = false;
@@ -5867,7 +6108,7 @@ async function scanKnowledge(snapshots, o) {
5867
6108
  }
5868
6109
  answered2 = true;
5869
6110
  for (const s2 of answer.superseded) {
5870
- const c = checkSuperseded(s2, pages);
6111
+ const c = checkSuperseded(s2, pages, snapshots);
5871
6112
  if ("problem" in c)
5872
6113
  problems.push(c.problem);
5873
6114
  else if (!superseded.some((x) => x.old.page === c.ok.old.page && x.old.source === c.ok.old.source))
@@ -5893,6 +6134,18 @@ async function scanKnowledge(snapshots, o) {
5893
6134
  continue;
5894
6135
  }
5895
6136
  seen.add(id);
6137
+ const other = takenBy.get(id);
6138
+ const at = c.ok.page.page;
6139
+ if (other && !(other.quote?.source === at.source && other.quote.page === at.pagePath)) {
6140
+ failed.push({
6141
+ id,
6142
+ kind: c.ok.item.kind,
6143
+ title: c.ok.item.title,
6144
+ page: at.pagePath,
6145
+ problems: [idTaken(id, other, at.source)]
6146
+ });
6147
+ continue;
6148
+ }
5896
6149
  kept.set(id, c.ok);
5897
6150
  }
5898
6151
  for (const [id, c] of kept) {
@@ -5966,6 +6219,10 @@ async function scanKnowledge(snapshots, o) {
5966
6219
  return true;
5967
6220
  }
5968
6221
  }
6222
+ var idTaken = (id, other, source) => {
6223
+ const where = other.quote ? other.quote.source === source ? other.quote.page : `${other.quote.source}/${other.quote.page}` : "another item";
6224
+ return `id ${id} is used by ${where}; choose another`;
6225
+ };
5969
6226
  var sameSet = (a, b) => a.length === b.length && [...a].sort().join("\n") === [...b].sort().join("\n");
5970
6227
  function checkScanAnswer(snapshots, output) {
5971
6228
  const pages = snapshots.flatMap((s2) => s2.pages.map((p) => preparePage(p, s2)));
@@ -5980,9 +6237,9 @@ function checkScanAnswer(snapshots, output) {
5980
6237
  return [`the answer isn't YAML: ${e.message.split("\n")[0]}`];
5981
6238
  }
5982
6239
  const problems = [];
5983
- const superseded = frontMatterSuperseded(pages);
6240
+ const superseded = frontMatterSuperseded(pages, snapshots);
5984
6241
  for (const s2 of answer.superseded) {
5985
- const c = checkSuperseded(s2, pages);
6242
+ const c = checkSuperseded(s2, pages, snapshots);
5986
6243
  if ("problem" in c)
5987
6244
  problems.push(c.problem);
5988
6245
  else
@@ -6085,6 +6342,11 @@ function copyDate(p) {
6085
6342
  }
6086
6343
  var isKnowledgeRecord = (r) => r.kind === "Pattern" || r.kind === "ProcessDefinition" || r.kind === "Decision" || r.kind === "Product" || r.kind === "Party" && !!r.quote;
6087
6344
 
6345
+ // packages/knowledge/dist/knowledge-store.js
6346
+ var import_yaml10 = __toESM(require_dist(), 1);
6347
+ import { readdir as readdir6, readFile as readFile6, rm as rm2 } from "node:fs/promises";
6348
+ import { join as join7, relative as relative3, sep as sep3 } from "node:path";
6349
+
6088
6350
  // packages/knowledge/dist/reviews.js
6089
6351
  var import_yaml9 = __toESM(require_dist(), 1);
6090
6352
  import { createHash as createHash4 } from "node:crypto";
@@ -6174,9 +6436,19 @@ function canonical(v) {
6174
6436
  return v;
6175
6437
  }
6176
6438
  function itemMeaning(r) {
6439
+ return meaningHash(r, false);
6440
+ }
6441
+ function itemMeaningBefore50(r) {
6442
+ return meaningHash(r, true);
6443
+ }
6444
+ function meaningHash(r, flagsAndTags) {
6177
6445
  const strip = (q) => q ? Object.fromEntries(Object.entries(q).filter(([k]) => k !== "snapshot" && k !== "line")) : q;
6178
6446
  const x = { ...r };
6179
6447
  delete x.evidence;
6448
+ if (!flagsAndTags) {
6449
+ delete x.flags;
6450
+ delete x.tags;
6451
+ }
6180
6452
  x.quote = strip(x.quote);
6181
6453
  if (Array.isArray(x.alsoOn))
6182
6454
  x.alsoOn = x.alsoOn.map(strip);
@@ -6265,7 +6537,7 @@ async function readReviews(root) {
6265
6537
  function applyReview(item, review) {
6266
6538
  if (!review)
6267
6539
  return { item };
6268
- const stale = review.checked !== itemMeaning(item);
6540
+ const stale = review.checked !== itemMeaning(item) && review.checked !== itemMeaningBefore50(item);
6269
6541
  const summary3 = {
6270
6542
  state: stale ? "stale" : review.verdict,
6271
6543
  verdict: review.verdict,
@@ -6274,16 +6546,13 @@ function applyReview(item, review) {
6274
6546
  ...review.note ? { note: review.note } : {},
6275
6547
  ...review.corrections ? { corrected: Object.keys(review.corrections).sort() } : {}
6276
6548
  };
6277
- if (!review.corrections)
6549
+ if (!review.corrections || stale)
6278
6550
  return { item, summary: summary3 };
6279
6551
  const merged = parseRecord({ ...item, ...review.corrections });
6280
6552
  return { item: merged.ok ? merged.record : item, summary: summary3 };
6281
6553
  }
6282
6554
 
6283
6555
  // packages/knowledge/dist/knowledge-store.js
6284
- var import_yaml10 = __toESM(require_dist(), 1);
6285
- import { readdir as readdir6, readFile as readFile6, rm as rm2 } from "node:fs/promises";
6286
- import { join as join7, relative as relative3, sep as sep3 } from "node:path";
6287
6556
  var KNOWLEDGE_REPORT = "scan.yaml";
6288
6557
  var toPosix3 = (p) => p.split(sep3).join("/");
6289
6558
  async function files(dir) {
@@ -6342,7 +6611,7 @@ async function readKnowledge(root, o = {}) {
6342
6611
  const a = applyReview(item, r.reviews.get(item.id));
6343
6612
  if (a.summary)
6344
6613
  reviews[item.id] = a.summary;
6345
- if (a.summary?.state === "rejected")
6614
+ if (a.summary?.verdict === "rejected")
6346
6615
  rejected.push(a.item);
6347
6616
  else
6348
6617
  shown.push(a.item);
@@ -6368,15 +6637,72 @@ async function writeKnowledge(root, result, scannedAt, o = {}) {
6368
6637
  return !pages || page === void 0 || pages.has(page);
6369
6638
  };
6370
6639
  const before = await readKnowledge(root, { raw: true, cacheRoot: root });
6371
- const pageText = (source, page) => o.snapshots?.find((x) => x.manifest.source === source)?.pages.find((p) => p.pagePath === page)?.text;
6640
+ const snapPage = (source, page) => {
6641
+ const snap = o.snapshots?.find((x) => x.manifest.source === source);
6642
+ const p = snap?.pages.find((x) => x.pagePath === page);
6643
+ return snap && p ? { snap, p } : void 0;
6644
+ };
6645
+ const pageText = (source, page) => snapPage(source, page)?.p.text;
6372
6646
  const stillQuoted = (r) => {
6373
6647
  if (!r.flags?.some((f) => f.startsWith("found:")) || !r.quote)
6374
6648
  return false;
6375
6649
  const text2 = pageText(r.quote.source, r.quote.page);
6376
6650
  return text2 !== void 0 && checkQuote(text2, r.quote.text, r.quote.section).ok;
6377
6651
  };
6378
- const keep = before.items.filter((r) => !touches(sourceOf(r), r.quote?.page) || stillQuoted(r));
6379
- const all = [...keep, ...result.items];
6652
+ const recheckAlsoOn = (r) => {
6653
+ if (!r.alsoOn.some((a) => touches(a.source, a.page)))
6654
+ return r;
6655
+ const alsoOn = [];
6656
+ const evidence = [...r.evidence];
6657
+ const paired = evidence.length === r.alsoOn.length + 1;
6658
+ const keptEvidence = paired ? [evidence[0]] : evidence;
6659
+ r.alsoOn.forEach((a, k) => {
6660
+ if (!touches(a.source, a.page)) {
6661
+ alsoOn.push(a);
6662
+ if (paired)
6663
+ keptEvidence.push(evidence[k + 1]);
6664
+ return;
6665
+ }
6666
+ const at = snapPage(a.source, a.page);
6667
+ const c = at ? checkQuote(at.p.text ?? "", a.text, a.section) : void 0;
6668
+ if (!at || !c?.ok)
6669
+ return;
6670
+ const m = at.snap.manifest.pages.find((x) => x.page === a.page);
6671
+ const snapshot = m?.in ?? at.snap.manifest.date;
6672
+ alsoOn.push({ ...a, section: c.section, line: c.line, snapshot });
6673
+ if (paired)
6674
+ keptEvidence.push({ ...evidence[k + 1], path: at.p.path, line: c.line });
6675
+ });
6676
+ return { ...r, alsoOn, evidence: keptEvidence };
6677
+ };
6678
+ const keep = before.items.filter((r) => !touches(sourceOf(r), r.quote?.page) || stillQuoted(r)).map(recheckAlsoOn);
6679
+ const keptById = new Map(keep.map((r) => [r.id, r]));
6680
+ const refused = [];
6681
+ const accepted = [];
6682
+ for (const r of result.items) {
6683
+ const k = keptById.get(r.id);
6684
+ if (k && !(k.quote?.source === r.quote?.source && k.quote?.page === r.quote?.page)) {
6685
+ refused.push({
6686
+ id: r.id,
6687
+ kind: knowledgeKindOf(r) ?? r.kind,
6688
+ title: itemTitle(r),
6689
+ ...r.quote ? { page: r.quote.page, source: r.quote.source } : {},
6690
+ problems: [idTaken(r.id, k, r.quote?.source ?? "")]
6691
+ });
6692
+ continue;
6693
+ }
6694
+ accepted.push(r);
6695
+ }
6696
+ const readNow = new Set(accepted.map((r) => r.id));
6697
+ const merged = [...keep.filter((r) => !readNow.has(r.id)), ...accepted];
6698
+ const refusedIds = new Set(refused.map((f) => f.id));
6699
+ const found = result.conflicts.filter((c) => !c.about.some((a) => refusedIds.has(a)));
6700
+ const conflicts = mergeConflicts(before.report?.conflicts ?? [], found, merged, {
6701
+ readNow,
6702
+ ...o.snapshots ? { snapshots: o.snapshots } : {},
6703
+ superseded: result.superseded
6704
+ });
6705
+ const all = merged.map((r) => withConflictFlags(r, conflicts));
6380
6706
  const dir = join7(knowledgeDirOf(root), "items");
6381
6707
  const wanted = new Map(all.map((r) => [recordPath(r), serializeRecord(r)]));
6382
6708
  let written = 0;
@@ -6439,7 +6765,7 @@ async function writeKnowledge(root, result, scannedAt, o = {}) {
6439
6765
  scannedAt,
6440
6766
  snapshots,
6441
6767
  changes: { at: scannedAt, ...changes },
6442
- conflicts: [...other(old?.conflicts), ...result.conflicts],
6768
+ conflicts,
6443
6769
  superseded: [
6444
6770
  ...(old?.superseded ?? []).filter((x) => !touches(x.old.source, x.old.page)),
6445
6771
  ...result.superseded
@@ -6450,11 +6776,62 @@ async function writeKnowledge(root, result, scannedAt, o = {}) {
6450
6776
  ...result.failed.map((f) => ({
6451
6777
  ...f,
6452
6778
  ...result.snapshots.length === 1 ? { source: result.snapshots[0].source } : {}
6453
- }))
6779
+ })),
6780
+ ...refused
6454
6781
  ]
6455
6782
  };
6456
6783
  await writeFileAtomic(join7(knowledgeDirOf(root), KNOWLEDGE_REPORT), (0, import_yaml10.stringify)(report));
6457
- return { written, removed, changes };
6784
+ return { written, removed, changes, ...refused.length ? { refused } : {} };
6785
+ }
6786
+ var sameAbout = (a, b) => a.length === b.length && [...a].sort().join("\n") === [...b].sort().join("\n");
6787
+ function mergeConflicts(old, found, items, o) {
6788
+ const byId2 = new Map(items.map((r) => [r.id, r]));
6789
+ const out = found.filter((c) => c.about.every((a) => byId2.has(a)));
6790
+ const has = (about) => out.some((c) => sameAbout(c.about, about));
6791
+ for (const c of old) {
6792
+ if (has(c.about) || !c.about.every((a) => byId2.has(a)))
6793
+ continue;
6794
+ const reread = c.about.filter((a) => o.readNow.has(a));
6795
+ if (c.foundBy === "check") {
6796
+ if (!reread.length) {
6797
+ out.push(c);
6798
+ continue;
6799
+ }
6800
+ const [x, y] = c.about.map((a) => byId2.get(a));
6801
+ const again = x && y && c.about.length === 2 ? recordConflict(x, y) : void 0;
6802
+ if (again)
6803
+ out.push({ ...again, ...c.owner ? { owner: c.owner } : {} });
6804
+ } else if (reread.length < c.about.length)
6805
+ out.push(c);
6806
+ }
6807
+ const facts2 = (o.snapshots ?? []).flatMap((s2) => s2.pages.map((p) => pageFacts(p, s2.manifest)));
6808
+ const kept = items.filter((r) => !o.readNow.has(r.id));
6809
+ for (const x of items.filter((r) => o.readNow.has(r.id)))
6810
+ for (const y of kept) {
6811
+ if (has([x.id, y.id]))
6812
+ continue;
6813
+ const c = recordConflict(x, y);
6814
+ if (!c)
6815
+ continue;
6816
+ const handledBy = [x, y].map((r) => "handledBy" in r ? r.handledBy : void 0).filter((h) => typeof h === "string");
6817
+ const owner = facts2.length ? conflictOwner(c, facts2, {
6818
+ ...knowledgeKindOf(x) ? { kind: knowledgeKindOf(x) } : {},
6819
+ ...new Set(handledBy).size === 1 ? { handledBy: handledBy[0] } : {}
6820
+ }, o.superseded) : void 0;
6821
+ out.push(owner ? { ...c, owner } : c);
6822
+ }
6823
+ return out;
6824
+ }
6825
+ function withConflictFlags(r, conflicts) {
6826
+ const mine = conflicts.filter((c) => c.about.includes(r.id)).map((c) => `conflict:${c.pages.map((p) => p.page).join("|")}`);
6827
+ const flags = [
6828
+ .../* @__PURE__ */ new Set([...(r.flags ?? []).filter((f) => !f.startsWith("conflict:")), ...mine.sort()])
6829
+ ];
6830
+ const same3 = flags.length === (r.flags ?? []).length && flags.every((f, k) => f === r.flags[k]);
6831
+ if (same3)
6832
+ return r;
6833
+ const { flags: _, ...rest } = r;
6834
+ return flags.length ? { ...rest, flags } : rest;
6458
6835
  }
6459
6836
  function filterItems(items, o) {
6460
6837
  const tag = o.tag?.toLowerCase();
@@ -7310,6 +7687,10 @@ function planRescan(snapshots, report, items, o = {}) {
7310
7687
  }
7311
7688
  return plan;
7312
7689
  }
7690
+ function keptBy(items, plan) {
7691
+ const previous = new Set(plan.previous);
7692
+ return items.filter((i) => !previous.has(i));
7693
+ }
7313
7694
 
7314
7695
  // packages/knowledge/dist/find.js
7315
7696
  var import_yaml12 = __toESM(require_dist(), 1);
@@ -7397,6 +7778,8 @@ async function findKnowledge(snapshots, phrase, o) {
7397
7778
  ...o.resume ? { resume: o.resume } : {},
7398
7779
  ...o.maxAttempts ? { maxAttempts: o.maxAttempts } : {},
7399
7780
  focus: { phrase, known },
7781
+ // Review round 50: an id an item of another page has is handed back, never reused.
7782
+ taken: o.items.filter((i) => !known.includes(i)),
7400
7783
  ...o.judgments ? { judgments: o.judgments } : {}
7401
7784
  });
7402
7785
  const ids = new Set(o.items.map((i) => i.id));
@@ -7426,8 +7809,8 @@ var FindFile = external_exports.object({
7426
7809
  var slugOf2 = (s2) => fold2(s2).replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "search";
7427
7810
  var findsDir = (root) => join10(knowledgeDirOf(root), FINDS_DIR);
7428
7811
  async function saveFind(root, r, at) {
7429
- const slug4 = slugOf2(r.phrase);
7430
- await writeFileAtomic(join10(findsDir(root), `${slug4}.yaml`), `# What a search of the wikis found (ADR 0101). atticus knowledge keep <candidate> --find ${slug4} keeps one.
7812
+ const slug5 = slugOf2(r.phrase);
7813
+ await writeFileAtomic(join10(findsDir(root), `${slug5}.yaml`), `# What a search of the wikis found (ADR 0101). atticus knowledge keep <candidate> --find ${slug5} keeps one.
7431
7814
  ${(0, import_yaml12.stringify)({
7432
7815
  schemaVersion: 1,
7433
7816
  phrase: r.phrase,
@@ -7435,10 +7818,10 @@ ${(0, import_yaml12.stringify)({
7435
7818
  matches: r.matches,
7436
7819
  candidates: r.candidates
7437
7820
  }, { lineWidth: 0 })}`);
7438
- return slug4;
7821
+ return slug5;
7439
7822
  }
7440
- async function readFind(root, slug4) {
7441
- const text2 = await readFile8(join10(findsDir(root), `${slug4}.yaml`), "utf8").catch(() => void 0);
7823
+ async function readFind(root, slug5) {
7824
+ const text2 = await readFile8(join10(findsDir(root), `${slug5}.yaml`), "utf8").catch(() => void 0);
7442
7825
  if (text2 === void 0)
7443
7826
  return void 0;
7444
7827
  const f = FindFile.safeParse((0, import_yaml12.parse)(text2));
@@ -7455,7 +7838,7 @@ async function readFind(root, slug4) {
7455
7838
  });
7456
7839
  }
7457
7840
  return {
7458
- slug: slug4,
7841
+ slug: slug5,
7459
7842
  phrase: f.data.phrase,
7460
7843
  at: f.data.at,
7461
7844
  matches: f.data.matches,
@@ -7484,14 +7867,14 @@ var KIND_FIELD = {
7484
7867
  Party: ["partyKind", (k) => k === "vendor" ? "vendor" : "internal-team"],
7485
7868
  Product: ["productKind", (k) => k]
7486
7869
  };
7487
- async function keepCandidate(root, slug4, id, o) {
7488
- const f = await readFind(root, slug4);
7870
+ async function keepCandidate(root, slug5, id, o) {
7871
+ const f = await readFind(root, slug5);
7489
7872
  if (!f)
7490
- return { error: `There is no saved search ${slug4}. atticus knowledge finds lists them.` };
7873
+ return { error: `There is no saved search ${slug5}. atticus knowledge finds lists them.` };
7491
7874
  const c = f.candidates.find((x) => x.record.id === id);
7492
7875
  if (!c)
7493
7876
  return {
7494
- error: `The search ${slug4} has no candidate ${id}: it has ${f.candidates.map((x) => x.record.id).join(", ")}.`
7877
+ error: `The search ${slug5} has no candidate ${id}: it has ${f.candidates.map((x) => x.record.id).join(", ")}.`
7495
7878
  };
7496
7879
  if (c.known)
7497
7880
  return {
@@ -7503,7 +7886,7 @@ async function keepCandidate(root, slug4, id, o) {
7503
7886
  if (!allowed.includes(as))
7504
7887
  return { error: `${id} can be kept as ${allowed.join(" or ")}.` };
7505
7888
  const [field, value] = KIND_FIELD[c.record.kind];
7506
- const flag = `found:${slug4}`;
7889
+ const flag = `found:${slug5}`;
7507
7890
  const parsed = parseRecord({
7508
7891
  ...c.record,
7509
7892
  [field]: value(as),
@@ -7525,7 +7908,7 @@ async function keepCandidate(root, slug4, id, o) {
7525
7908
  await writeReview(root, r.review);
7526
7909
  c.kept = { by: o.by, at: o.at, as };
7527
7910
  c.record = item;
7528
- await writeFileAtomic(join10(findsDir(root), `${slug4}.yaml`), `# What a search of the wikis found (ADR 0101). atticus knowledge keep <candidate> --find ${slug4} keeps one.
7911
+ await writeFileAtomic(join10(findsDir(root), `${slug5}.yaml`), `# What a search of the wikis found (ADR 0101). atticus knowledge keep <candidate> --find ${slug5} keeps one.
7529
7912
  ${(0, import_yaml12.stringify)({
7530
7913
  schemaVersion: 1,
7531
7914
  phrase: f.phrase,
@@ -7945,15 +8328,149 @@ ${(0, import_yaml14.stringify)({ ...draft2, proposals: left }, { lineWidth: 0 })
7945
8328
  };
7946
8329
  }
7947
8330
 
8331
+ // packages/knowledge/dist/passages.js
8332
+ var MAX_TEXT = 1500;
8333
+ var clip = (s2) => s2.length > MAX_TEXT ? `${s2.slice(0, MAX_TEXT - 1).trimEnd()}\u2026` : s2;
8334
+ function visibleLines(text2) {
8335
+ const raw = text2.replace(/\r\n?/g, "\n").split("\n");
8336
+ const lines = visibleText(raw.join("\n")).split("\n").map((l, i) => l === raw[i] ? l : l.replace(/[ \t]{2,}/g, " ").trimEnd());
8337
+ let from = 0;
8338
+ if (lines[0]?.trim() === "---") {
8339
+ const end = lines.findIndex((l, k) => k > 0 && (l.trim() === "---" || l.trim() === "..."));
8340
+ if (end > 0) {
8341
+ for (let k = 0; k <= end; k++)
8342
+ lines[k] = "";
8343
+ from = end + 1;
8344
+ }
8345
+ }
8346
+ return { lines, from };
8347
+ }
8348
+ function pageSections(p) {
8349
+ const { lines, from } = visibleLines(p.text);
8350
+ const out = [];
8351
+ const path = [];
8352
+ let start = from;
8353
+ let heading = "";
8354
+ const flush = (end) => {
8355
+ const body = lines.slice(start, end);
8356
+ const text2 = body.filter((l, i) => !(i === 0 && /^#{1,6}\s/.test(l))).join("\n").trim();
8357
+ if (text2 || heading)
8358
+ out.push({
8359
+ source: p.source,
8360
+ page: p.page,
8361
+ path: p.path,
8362
+ heading,
8363
+ line: start + 1,
8364
+ text: clip(text2)
8365
+ });
8366
+ };
8367
+ let inFence = false;
8368
+ lines.forEach((l, i) => {
8369
+ if (/^\s*(```|~~~)/.test(l))
8370
+ inFence = !inFence;
8371
+ const h = inFence ? null : /^(#{1,6})\s+(.*?)\s*#*\s*$/.exec(l);
8372
+ if (!h)
8373
+ return;
8374
+ if (i > start || heading)
8375
+ flush(i);
8376
+ const level = h[1].length;
8377
+ while (path.length && path.at(-1).level >= level)
8378
+ path.pop();
8379
+ path.push({ level, text: h[2] });
8380
+ heading = path.map((x) => x.text).join(" \u203A ");
8381
+ start = i;
8382
+ });
8383
+ flush(lines.length);
8384
+ return out.filter((s2) => s2.text || s2.heading);
8385
+ }
8386
+ var slug4 = (s2) => s2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
8387
+ function sectionOf(pages, id) {
8388
+ const hash = id.indexOf("#");
8389
+ const where = hash < 0 ? id : id.slice(0, hash);
8390
+ const want = hash < 0 ? "" : id.slice(hash + 1).trim();
8391
+ const page = pages.find((p) => `${p.source}/${p.page}` === where || p.path === where || p.page === where);
8392
+ if (!page)
8393
+ return void 0;
8394
+ const sections = pageSections(page);
8395
+ if (!want)
8396
+ return sections[0];
8397
+ const w = want.toLowerCase();
8398
+ const last = (h) => h.split(" \u203A ").at(-1) ?? h;
8399
+ return sections.find((s2) => s2.heading.toLowerCase() === w || last(s2.heading).toLowerCase() === w) ?? sections.find((s2) => slug4(s2.heading) === slug4(want) || slug4(last(s2.heading)) === slug4(want)) ?? sections.find((s2) => slug4(want).endsWith(slug4(last(s2.heading))) && slug4(last(s2.heading)));
8400
+ }
8401
+ function rankPassages(question, pages, limit = 5) {
8402
+ const q = [...new Set(termsOf(question))];
8403
+ if (!q.length)
8404
+ return [];
8405
+ const all = pages.flatMap(pageSections);
8406
+ const docs = all.map((s2) => new Set(termsOf(`${s2.heading} ${s2.text}`)));
8407
+ const idf = new Map(q.map((t) => [t, Math.log(1 + all.length / (1 + docs.filter((d) => d.has(t)).length))]));
8408
+ const need = q.length > 2 ? 2 : 1;
8409
+ return all.map((s2, k) => {
8410
+ const hits = q.filter((t) => docs[k].has(t));
8411
+ const heading = new Set(termsOf(s2.heading));
8412
+ const score = hits.reduce((n, t) => n + idf.get(t) * (heading.has(t) ? 1.5 : 1), 0);
8413
+ return { s: s2, hits: hits.length, score };
8414
+ }).filter((x) => x.hits >= need).sort((a, b) => b.score - a.score || a.s.path.localeCompare(b.s.path) || a.s.line - b.s.line).slice(0, limit).map((x) => x.s);
8415
+ }
8416
+ function knowledgeAnswer(question, o) {
8417
+ const limit = o.limit ?? 5;
8418
+ const q = termsOf(question);
8419
+ const need = new Set(q).size > 2 ? 2 : 1;
8420
+ const items = rankItems(question, [...o.items]).filter((x) => {
8421
+ const own = new Set(termsOf(`${itemTitle(x.item)} ${x.item.quote?.text ?? ""} ${x.item.tags.join(" ")}`));
8422
+ return [...new Set(q)].filter((t) => own.has(t)).length >= need;
8423
+ }).slice(0, limit).map(({ item }) => ({
8424
+ id: item.id,
8425
+ kind: item.kind,
8426
+ title: itemTitle(item),
8427
+ ...item.quote ? {
8428
+ quote: {
8429
+ source: item.quote.source,
8430
+ page: item.quote.page,
8431
+ ...item.quote.section ? { section: item.quote.section } : {},
8432
+ text: item.quote.text
8433
+ }
8434
+ } : {}
8435
+ }));
8436
+ return { items, passages: rankPassages(question, o.pages, limit) };
8437
+ }
8438
+
7948
8439
  export {
8440
+ frontMatterEnd,
8441
+ readMarkdown,
8442
+ sentences,
8443
+ mentionIndex,
8444
+ decodeEntities,
8445
+ htmlToMarkdown,
8446
+ elementInner,
8447
+ exportDate,
8448
+ exportPage,
8449
+ titleSegment,
8450
+ uniquePagePaths,
8451
+ readCsv,
8452
+ confluenceExportAdapter,
8453
+ sharepointExportAdapter,
7949
8454
  readSourceSettings,
8455
+ pageSignalsOf,
7950
8456
  pageStandingOf,
8457
+ bodyKey,
8458
+ pageRestricted,
8459
+ authorityWords,
7951
8460
  scopeWords,
8461
+ exceptionTo,
7952
8462
  emptyPlaces,
7953
8463
  scopeMatch,
8464
+ markdownFolderAdapter,
8465
+ wikiApiAdapter,
7954
8466
  daysBetween,
8467
+ pageOwnerLine,
7955
8468
  readPage,
7956
8469
  syncSources,
8470
+ sourceDocument,
8471
+ reachesItem,
8472
+ mapFacts,
8473
+ reachesItems,
7957
8474
  judgeFacts,
7958
8475
  scanPatterns,
7959
8476
  diffPatterns,
@@ -7976,50 +8493,101 @@ export {
7976
8493
  workItemsFromTracker,
7977
8494
  suggestFeatureLinks,
7978
8495
  featureFlows,
8496
+ FEATURE_CHECKS,
8497
+ NAME_ABBREVIATIONS,
8498
+ nameWords2 as nameWords,
8499
+ abbreviates,
7979
8500
  namingHint,
8501
+ glossaryTermKnown,
7980
8502
  newestEvidence,
8503
+ freshness,
8504
+ KNOWLEDGE_CHECKS,
7981
8505
  knowledgeGaps,
8506
+ COVERAGE_AREAS,
7982
8507
  featureCoverage,
7983
8508
  coverage,
7984
8509
  toApiCoverage,
8510
+ DEFAULT_DOMAIN_PROFILE,
7985
8511
  domainProfile,
8512
+ visibleText,
8513
+ pageLines,
8514
+ foldQuote,
8515
+ readerText,
7986
8516
  checkQuote,
8517
+ valueTokens,
8518
+ groundValues,
7987
8519
  workingDays,
8520
+ LEAD_TIME,
8521
+ leadTimeInputs,
7988
8522
  leadTimeDaysOf,
8523
+ settleClaims,
7989
8524
  tagList,
7990
8525
  setSourceTags,
7991
8526
  SNAPSHOT_FILE,
7992
8527
  SnapshotManifest,
8528
+ sourceTags,
7993
8529
  writeSnapshots,
8530
+ readManifest,
8531
+ snapshotCopyPath,
7994
8532
  snapshotDates,
7995
8533
  snapshotSources,
7996
8534
  readSnapshot,
7997
8535
  snapshotPages,
8536
+ linksIn,
8537
+ sectionAt,
7998
8538
  pageFacts,
8539
+ conflictOwner,
8540
+ KNOWLEDGE_READER,
7999
8541
  KNOWLEDGE_SCAN_OUTPUT,
8542
+ knowledgeReaderAgent,
8543
+ preparePage,
8544
+ SCAN_ROOM_RESERVE,
8000
8545
  knowledgeScanRoom,
8546
+ recordConflict,
8001
8547
  scanKnowledge,
8548
+ idTaken,
8002
8549
  checkScanAnswer,
8550
+ isKnowledgeRecord,
8551
+ REVIEWS_DIR,
8552
+ KnowledgeReview,
8003
8553
  correctableFields,
8004
8554
  fieldName,
8555
+ itemMeaning,
8556
+ itemMeaningBefore50,
8005
8557
  reviewItem,
8006
8558
  writeReview,
8007
8559
  readReviews,
8560
+ applyReview,
8561
+ KNOWLEDGE_REPORT,
8008
8562
  readKnowledge,
8009
8563
  writeKnowledge,
8010
8564
  filterItems,
8011
8565
  itemTitle,
8566
+ KNOWLEDGE_ASK_OUTPUT,
8567
+ KNOWLEDGE_ASKER,
8568
+ knowledgeAskerAgent,
8012
8569
  termsOf,
8570
+ rankItems,
8013
8571
  itemForAi,
8014
8572
  askKnowledge,
8573
+ valuesOf,
8574
+ codeSettles,
8575
+ snapshotPageReader,
8576
+ standingSuggestion,
8015
8577
  CONFLICT_STEP,
8578
+ conflictKey,
8579
+ conflictKeyOfQuestion,
8016
8580
  conflictDraft,
8017
8581
  readConflicts,
8018
8582
  conflictLine,
8019
8583
  codeText,
8584
+ unquoteGitPath,
8020
8585
  checkoutGitWiki,
8021
8586
  gitWikiAdapter,
8587
+ tokensOf,
8022
8588
  planRescan,
8589
+ keptBy,
8590
+ FINDS_DIR,
8023
8591
  searchPages,
8024
8592
  findKnowledge,
8025
8593
  saveFind,
@@ -8030,6 +8598,11 @@ export {
8030
8598
  draftOrgPack,
8031
8599
  acceptOrgPackDraft,
8032
8600
  estimateScan,
8601
+ StandardCheckProposal,
8033
8602
  draftStandardChecks,
8034
- acceptStandardChecks
8603
+ acceptStandardChecks,
8604
+ pageSections,
8605
+ sectionOf,
8606
+ rankPassages,
8607
+ knowledgeAnswer
8035
8608
  };