@iowarp/clio-coder 0.4.7 → 0.4.9

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 (675) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +111 -0
  3. package/CONTRIBUTING.md +83 -74
  4. package/README.md +69 -47
  5. package/dist/{acp-W3Y3TRHD.js → acp-ZWZCPS2A.js} +15 -15
  6. package/dist/{agents-J4ICNLQ3.js → agents-LYSOWZUE.js} +61 -59
  7. package/dist/assets/codewiki.json +1 -1
  8. package/dist/assets/web-notices/@hono__node-server-LICENSE +21 -0
  9. package/dist/assets/web-notices/hono-LICENSE +21 -0
  10. package/dist/{auth-X2UJUMOC.js → auth-WBQGKWQ5.js} +27 -27
  11. package/dist/background-BUMOBAQN.js +37 -0
  12. package/dist/{builtins-XLXWWSRF.js → builtins-ODRJOEDI.js} +7 -7
  13. package/dist/{chunk-C3G5PNUO.js → chunk-2DRRZ57Q.js} +36 -27
  14. package/dist/chunk-2JBZYUPY.js +105 -0
  15. package/dist/chunk-2KUBKL63.js +336 -0
  16. package/dist/chunk-2VBWFXYE.js +198 -0
  17. package/dist/{chunk-XZ6UFQ52.js → chunk-2X2R3UTH.js} +25 -15
  18. package/dist/{chunk-M6Z2V6YU.js → chunk-37LW32LZ.js} +5 -5
  19. package/dist/{chunk-6LRLOJHQ.js → chunk-3AND2EFU.js} +11 -62
  20. package/dist/{chunk-FQOOGXBH.js → chunk-3RDHGNU7.js} +101 -33
  21. package/dist/{chunk-D2T66PDV.js → chunk-3SUDBGEI.js} +41 -208
  22. package/dist/{chunk-5AJPUR72.js → chunk-3TQN67I2.js} +9 -9
  23. package/dist/{chunk-LBFQMYS3.js → chunk-3U4BL2EV.js} +5 -3
  24. package/dist/{chunk-UFYNOQK4.js → chunk-3UQADNG2.js} +7 -7
  25. package/dist/{chunk-V4ZKOKRB.js → chunk-434LRQ6Z.js} +61 -53
  26. package/dist/{chunk-NO7J45X6.js → chunk-4ATBOFRP.js} +713 -218
  27. package/dist/{chunk-ECOMVOHP.js → chunk-4DNL43EZ.js} +3 -3
  28. package/dist/{chunk-WT5TRMO4.js → chunk-4HFJKRGZ.js} +255 -82
  29. package/dist/{chunk-5A6XR3RJ.js → chunk-555E2WVV.js} +16 -2
  30. package/dist/{chunk-WURGVOZJ.js → chunk-5RTEFNBP.js} +18 -14
  31. package/dist/{config-YXARKGTX.js → chunk-64XJW7NT.js} +24 -268
  32. package/dist/{chunk-24S3DN22.js → chunk-6TKOFFGE.js} +4 -4
  33. package/dist/{chunk-YKRJTYNP.js → chunk-6UJ7RDI7.js} +4 -4
  34. package/dist/{chunk-MZNWZUJM.js → chunk-7FBCRWVT.js} +288 -288
  35. package/dist/{chunk-UA6W4XFJ.js → chunk-7JSOSVLP.js} +2 -2
  36. package/dist/chunk-7N3OLLSL.js +637 -0
  37. package/dist/{chunk-KKEYGFX4.js → chunk-7QQRPB2E.js} +11 -11
  38. package/dist/{chunk-N37QC5FV.js → chunk-A6DULIMH.js} +21 -9
  39. package/dist/{fleet-decisions-S3PTZV2D.js → chunk-AB3QXXBC.js} +5 -41
  40. package/dist/chunk-ACCECAH4.js +49 -0
  41. package/dist/{chunk-CP3HIR5H.js → chunk-AM6CEP2K.js} +20 -19
  42. package/dist/chunk-AUHVBIDW.js +19 -0
  43. package/dist/{chunk-BQQ5MXUC.js → chunk-AY4XE6GN.js} +19 -13
  44. package/dist/{chunk-ISNCCX42.js → chunk-BBA2TAWV.js} +10 -9
  45. package/dist/chunk-BFPHMSK7.js +169 -0
  46. package/dist/{chunk-LVFANMOH.js → chunk-BHJMMCXS.js} +4 -4
  47. package/dist/{chunk-DO7M3LSX.js → chunk-BMNVVKEW.js} +40 -93
  48. package/dist/{chunk-VTYHHQ57.js → chunk-CTGZCEI6.js} +2 -2
  49. package/dist/{chunk-RTLNFZMD.js → chunk-DIAJYJYG.js} +3 -3
  50. package/dist/chunk-EHZRAB4U.js +63 -0
  51. package/dist/{chunk-KS7ETA3P.js → chunk-EM2DIQAJ.js} +3 -3
  52. package/dist/{chunk-MNQN3X6Y.js → chunk-ETF4ROKH.js} +5 -5
  53. package/dist/{chunk-WN552PKN.js → chunk-F2YM3JY4.js} +744 -1134
  54. package/dist/{chunk-7EEGBKV4.js → chunk-FEBQWHJT.js} +24 -19
  55. package/dist/{chunk-4QKAITQT.js → chunk-FPS4R2RN.js} +74 -10
  56. package/dist/chunk-G5R53COU.js +68 -0
  57. package/dist/chunk-GHXGMFQ5.js +40 -0
  58. package/dist/{chunk-GFQ7P2UF.js → chunk-GJDRMBDI.js} +10 -10
  59. package/dist/{chunk-LZBMXNLP.js → chunk-GM4TY6VN.js} +43 -6
  60. package/dist/{chunk-NCCQ6DVS.js → chunk-GREYLTZ5.js} +8 -8
  61. package/dist/{chunk-HOX4YZ2K.js → chunk-H2WSCZZT.js} +19 -3
  62. package/dist/{chunk-3LXJOICS.js → chunk-H6IUCY6Q.js} +2 -2
  63. package/dist/{chunk-BO4XV5VX.js → chunk-H72DCH3E.js} +95 -206
  64. package/dist/{chunk-SEDI5K5B.js → chunk-H7TXJR23.js} +20 -20
  65. package/dist/chunk-HBJQQTKM.js +40 -0
  66. package/dist/chunk-HCVKSGNZ.js +990 -0
  67. package/dist/chunk-HVCAY2FH.js +67 -0
  68. package/dist/{chunk-34XHRVKG.js → chunk-I47EJPYL.js} +3 -3
  69. package/dist/{chunk-4N2RZ4TO.js → chunk-IALGWTLO.js} +3 -3
  70. package/dist/{chunk-IQCNVLO6.js → chunk-IALZJE37.js} +10 -7
  71. package/dist/{chunk-DLIYANB7.js → chunk-IC7JXLOM.js} +16 -11
  72. package/dist/{chunk-G4LGUTOE.js → chunk-IOSVTTCD.js} +5 -5
  73. package/dist/{chunk-DBREN25X.js → chunk-IPTPMLA6.js} +8 -3
  74. package/dist/{chunk-V552WL53.js → chunk-IZZI3SKQ.js} +3 -67
  75. package/dist/{chunk-TN5FW4XY.js → chunk-JIYWMQZ5.js} +12 -9
  76. package/dist/{chunk-T7QQBNLH.js → chunk-JKU34ACI.js} +10 -8
  77. package/dist/chunk-JOBN2YQQ.js +176 -0
  78. package/dist/chunk-JOL2QRLE.js +152 -0
  79. package/dist/{chunk-GXIWHXDB.js → chunk-JTR3VSV3.js} +3 -3
  80. package/dist/{chunk-T334FW2H.js → chunk-JU6MAMRJ.js} +7 -7
  81. package/dist/chunk-JURMQWVJ.js +15 -0
  82. package/dist/{chunk-CULVKYTK.js → chunk-K3XN4LZ4.js} +5 -5
  83. package/dist/{chunk-3T4DXWP6.js → chunk-KIVFXGBM.js} +27 -7
  84. package/dist/chunk-KKRXONXG.js +43 -0
  85. package/dist/{chunk-YPRSNUTC.js → chunk-KOAHT3N2.js} +2 -2
  86. package/dist/chunk-KP5BPXR3.js +73 -0
  87. package/dist/{chunk-UA3W4FGC.js → chunk-KRJQG47M.js} +6 -6
  88. package/dist/{chunk-GI5RRMAH.js → chunk-KW6OJ7IY.js} +19 -21
  89. package/dist/{chunk-A46ILRS2.js → chunk-L3NBWLSN.js} +4 -4
  90. package/dist/{chunk-MZHXENL7.js → chunk-L4RUTLRL.js} +8 -8
  91. package/dist/{chunk-P5SC4DLJ.js → chunk-LGTVWPRN.js} +2 -2
  92. package/dist/{chunk-65BGHOUR.js → chunk-LSQW6KZO.js} +5 -5
  93. package/dist/{chunk-TZHN5ITX.js → chunk-LWJYOHT3.js} +8 -8
  94. package/dist/{chunk-U3TPUXOQ.js → chunk-M6YLF66Z.js} +74 -40
  95. package/dist/chunk-MJ4QEJVT.js +185 -0
  96. package/dist/{chunk-T4TY5GG3.js → chunk-MO65K5CH.js} +5 -5
  97. package/dist/{chunk-TZ6UVP2H.js → chunk-MTOZEQHL.js} +8 -8
  98. package/dist/chunk-MZDPF35R.js +45 -0
  99. package/dist/{chunk-P4DL2LM5.js → chunk-MZKYVIWW.js} +8 -119
  100. package/dist/{chunk-KAFMW7WM.js → chunk-NBPA5QM6.js} +2 -2
  101. package/dist/{chunk-EUEXGXXR.js → chunk-NMBEW4PP.js} +5 -5
  102. package/dist/{chunk-SELG4SUR.js → chunk-NPLLK3HO.js} +72 -89
  103. package/dist/{chunk-VCRVEDUC.js → chunk-NSYGPIVW.js} +5 -5
  104. package/dist/{context-7HJEWTTP.js → chunk-NXTV5OI5.js} +36 -90
  105. package/dist/{chunk-IMOD2YPV.js → chunk-NYDG4QP4.js} +9 -19
  106. package/dist/{chunk-6CA2BHOR.js → chunk-OA2GDACN.js} +5 -5
  107. package/dist/{chunk-A67NR5AT.js → chunk-PJI57EC6.js} +14 -11
  108. package/dist/{chunk-IJMW64DX.js → chunk-PJJBUGMR.js} +50 -50
  109. package/dist/{chunk-CPXGJI2A.js → chunk-PNJE7JPS.js} +20 -5
  110. package/dist/chunk-PP23PZEV.js +1347 -0
  111. package/dist/chunk-PPIFDSBK.js +409 -0
  112. package/dist/{chunk-T52TPHYC.js → chunk-PTFISXQO.js} +8 -7
  113. package/dist/{chunk-C6GEXX4L.js → chunk-QB33Z5S7.js} +5 -5
  114. package/dist/{chunk-VMATUZB6.js → chunk-QGNII5VC.js} +10 -10
  115. package/dist/{chunk-TLTGZTXI.js → chunk-QI72X67S.js} +104 -27
  116. package/dist/chunk-QKHZZFKH.js +98 -0
  117. package/dist/{chunk-PFLOULP3.js → chunk-RDKX2PME.js} +4 -4
  118. package/dist/{chunk-B5ZTR6KZ.js → chunk-RL7LJYN4.js} +1 -1
  119. package/dist/chunk-RPMNIFRY.js +65 -0
  120. package/dist/{chunk-L3Z5ANCV.js → chunk-RQROVOV3.js} +13 -11
  121. package/dist/{chunk-6YHPAAZR.js → chunk-S34A7BSP.js} +3 -3
  122. package/dist/{chunk-5ZSZEYJK.js → chunk-SJETVJHX.js} +2 -2
  123. package/dist/{chunk-77CZRFTE.js → chunk-SJMNU4ZS.js} +2 -2
  124. package/dist/chunk-SLLG2G44.js +85 -0
  125. package/dist/{chunk-GVZFCJHE.js → chunk-SQAZN2V3.js} +48 -22
  126. package/dist/{chunk-2O2LVQQK.js → chunk-SQBT46OF.js} +2 -2
  127. package/dist/{chunk-ZGIGW4ZG.js → chunk-TCUOGIL2.js} +5 -5
  128. package/dist/{chunk-DACXIVVF.js → chunk-TIWPKCVO.js} +5 -5
  129. package/dist/{chunk-5CMARGPF.js → chunk-UIU7MGZ3.js} +11 -2
  130. package/dist/chunk-USBBEKHW.js +177 -0
  131. package/dist/{chunk-WLHX3MM5.js → chunk-V4XJWDHR.js} +21 -11
  132. package/dist/{chunk-MBJO5VNZ.js → chunk-VPWGADBG.js} +33 -33
  133. package/dist/{chunk-UUQ5G6EZ.js → chunk-VWFCAK34.js} +6 -6
  134. package/dist/{chunk-6CB2IL4N.js → chunk-W5RM7YAH.js} +1 -1
  135. package/dist/{chunk-4MFBBY2Z.js → chunk-W72LLZAV.js} +3 -3
  136. package/dist/{chunk-4UHVS5T7.js → chunk-WGRDABW7.js} +8 -8
  137. package/dist/{chunk-XR3XJN2M.js → chunk-WWRV5RJI.js} +4 -4
  138. package/dist/{chunk-24TOGHPO.js → chunk-X6FLVUM5.js} +4 -4
  139. package/dist/{chunk-6YA46L5A.js → chunk-XFLSL7BT.js} +2 -2
  140. package/dist/{chunk-QKWL7SYE.js → chunk-XJZEDCNT.js} +50 -39
  141. package/dist/{chunk-UWD3JD5X.js → chunk-XLLEL3K7.js} +10 -10
  142. package/dist/{chunk-2GPGAE5W.js → chunk-XNIZBOFV.js} +15 -1
  143. package/dist/chunk-XNZWWDC3.js +686 -0
  144. package/dist/{chunk-WBVKKTUT.js → chunk-XRECG65F.js} +2 -2
  145. package/dist/chunk-XTQ7MEJG.js +457 -0
  146. package/dist/{chunk-GEVQNST4.js → chunk-XZWSP67B.js} +2 -2
  147. package/dist/{chunk-WB7POC6M.js → chunk-Y3M2T5RO.js} +6 -6
  148. package/dist/{chunk-RXFPB32E.js → chunk-YJCCMYYT.js} +2 -2
  149. package/dist/{chunk-EUZRMP4Y.js → chunk-YPQOPFP7.js} +20 -20
  150. package/dist/{chunk-USZA7GWL.js → chunk-YQ3GFEUY.js} +2 -2
  151. package/dist/{chunk-BAU36233.js → chunk-YQYINEJI.js} +9 -9
  152. package/dist/{chunk-CE64C5K5.js → chunk-ZF6CV4WZ.js} +1356 -235
  153. package/dist/{chunk-3XE4NRLF.js → chunk-ZKJU55MX.js} +4 -2
  154. package/dist/{chunk-IZYTT3CD.js → chunk-ZKQ63XZ5.js} +16 -39
  155. package/dist/{chunk-6TAATXXH.js → chunk-ZKVMDNAN.js} +7 -7
  156. package/dist/chunk-ZST3FRCV.js +132 -0
  157. package/dist/cli/index.js +50 -38
  158. package/dist/{clio-L2P7S2R2.js → clio-JUDCLNHC.js} +11 -11
  159. package/dist/clio-context-tools-FT672MNZ.js +136 -0
  160. package/dist/{code-nav-B5LNX4KU.js → code-nav-7OVCTP2Z.js} +39 -37
  161. package/dist/{components-63MMQKUT.js → components-OZXZMDWU.js} +11 -11
  162. package/dist/config-P3ZQVF63.js +275 -0
  163. package/dist/config-graph-GKAOBAS5.js +160 -0
  164. package/dist/{configure-LMVQJ46J.js → configure-25LRYZJG.js} +56 -55
  165. package/dist/context-72VQV7JX.js +73 -0
  166. package/dist/{context-YG2LZDYZ.js → context-COWRWXP3.js} +89 -83
  167. package/dist/{context-XSZKKFBW.js → context-WB3D474G.js} +16 -16
  168. package/dist/{context-clear-AC5NXHM2.js → context-clear-Y4LYMWC6.js} +88 -82
  169. package/dist/{context-index-KKTPRV5G.js → context-index-W6A4V7OC.js} +4 -4
  170. package/dist/{context-map-T7ROR5D5.js → context-map-DKL3QT6D.js} +3 -3
  171. package/dist/{context-working-set-F4Q4J3NS.js → context-working-set-TMZYVC7A.js} +27 -25
  172. package/dist/data-tool-KMBWKKWR.js +2987 -0
  173. package/dist/{detail-H73BEF2N.js → detail-4GLROGY5.js} +89 -83
  174. package/dist/{dispatch-runner-3RY5FSJC.js → dispatch-runner-TR3LBP5P.js} +113 -107
  175. package/dist/docs-ZK777W2G.js +101 -0
  176. package/dist/{doctor-EQYJOGUG.js → doctor-WC4OV2OB.js} +76 -73
  177. package/dist/{eval-4P7O6CCE.js → eval-FUNWJNUJ.js} +88 -73
  178. package/dist/{eval-inventory-QOYZERXJ.js → eval-inventory-CX24K2JT.js} +5 -60
  179. package/dist/evals-L73EBHSU.js +104 -0
  180. package/dist/{evidence-O76QF7TZ.js → evidence-AVJ2RTHX.js} +99 -93
  181. package/dist/{evidence-D6GUSYJW.js → evidence-P4NZOAK7.js} +88 -82
  182. package/dist/evidence-Y55WKYHH.js +246 -0
  183. package/dist/{evolve-H47BCETS.js → evolve-MAWKRYWF.js} +93 -87
  184. package/dist/{extensions-NNL3ZOCU.js → extensions-PYQH3H47.js} +14 -13
  185. package/dist/fleet-M4H2QBWT.js +268 -0
  186. package/dist/{fleet-KMNS6NOM.js → fleet-ULBXXRDR.js} +146 -138
  187. package/dist/{fleet-commands-DOWSYCBX.js → fleet-commands-7NNC4JZU.js} +18 -17
  188. package/dist/fleet-decisions-EHEY7KPU.js +52 -0
  189. package/dist/{fleet-graph-F2DE2TME.js → fleet-graph-LQ2AHZT3.js} +24 -24
  190. package/dist/{fleet-inspect-EN2Q6IVB.js → fleet-inspect-5IGBIIYZ.js} +98 -258
  191. package/dist/{fleet-preflight-FRLETDD3.js → fleet-preflight-UTTNOKMG.js} +9 -4
  192. package/dist/{fleet-validate-B2XDLS57.js → fleet-validate-YGILJKA6.js} +29 -29
  193. package/dist/{fleet-verify-4JKUWGJ7.js → fleet-verify-AUWTCDKR.js} +88 -82
  194. package/dist/{fleet-view-BHJFW26B.js → fleet-view-TGUFCY5A.js} +90 -84
  195. package/dist/{init-XAT5N5YM.js → init-GFN2Z7NF.js} +111 -104
  196. package/dist/install-6PIF6F6W.js +19 -0
  197. package/dist/{interop-FVECHFKG.js → interop-EF5JUWWK.js} +29 -29
  198. package/dist/{inventory-7KFQGLCV.js → inventory-I6VJDDYF.js} +90 -84
  199. package/dist/library-3J5IO2OJ.js +75 -0
  200. package/dist/{library-QAPAO23R.js → library-IJTOFTDS.js} +20 -19
  201. package/dist/{library-NY2XOT75.js → library-Z3KZSHPE.js} +35 -35
  202. package/dist/{library-import-5Y6MAS3R.js → library-import-IMKFLDHX.js} +29 -29
  203. package/dist/{library-inventory-JT6HWITQ.js → library-inventory-CQP5D6GU.js} +21 -21
  204. package/dist/{library-validation-EQUH25DC.js → library-validation-33UTX7AI.js} +19 -19
  205. package/dist/mcp-5FWZKUS6.js +26 -0
  206. package/dist/{memory-DYVTTCP6.js → memory-36CWN67Y.js} +93 -87
  207. package/dist/{models-MASFJ6Y2.js → models-KQ6PQJJQ.js} +57 -56
  208. package/dist/{monitor-YMP4NXJJ.js → monitor-XX6ZD6KC.js} +98 -91
  209. package/dist/{orchestrator-AFQRRTEI.js → orchestrator-SK6HDAOP.js} +1537 -832
  210. package/dist/{panes-NICTHQCV.js → panes-L27QRXUH.js} +14 -14
  211. package/dist/{panes-D3Y2KFG5.js → panes-LXZIWNOZ.js} +4 -4
  212. package/dist/{paths-PSFAUIGO.js → paths-7DJDU4P4.js} +6 -6
  213. package/dist/{preload-5Q7VXRFJ.js → preload-K2TDYI4Y.js} +88 -82
  214. package/dist/{reset-7NKZK7JN.js → reset-73VU3XNT.js} +13 -13
  215. package/dist/{resources-NILSIZAT.js → resources-3BYJYVYL.js} +24 -24
  216. package/dist/{run-BPZGEBZV.js → run-AR7PY6GW.js} +144 -136
  217. package/dist/run-script-H2KUDIII.js +41 -0
  218. package/dist/settings-3VMBMWID.js +72 -0
  219. package/dist/{share-EZ6ERBMH.js → share-HVWH4FPF.js} +30 -30
  220. package/dist/{skills-BTVVNYVM.js → skills-5TYEY75Q.js} +30 -30
  221. package/dist/{skills-eval-UY34MNK7.js → skills-eval-CK3MD63Z.js} +114 -103
  222. package/dist/{skills-inventory-JDHSIA7I.js → skills-inventory-KSFYG3I6.js} +24 -24
  223. package/dist/{slash-commands-K4FNQ2AT.js → slash-commands-DMVHML7P.js} +60 -57
  224. package/dist/{steer-2B3EQGFH.js → steer-XCD6V3EW.js} +4 -4
  225. package/dist/{support-L2SOL3IE.js → support-JAZL6VBR.js} +7 -7
  226. package/dist/system-3TDQRMZZ.js +116 -0
  227. package/dist/{targets-44VKGFLN.js → targets-EZKHAYRN.js} +74 -72
  228. package/dist/{tasks-3KODKFU7.js → tasks-SNEFHWYW.js} +18 -18
  229. package/dist/{terminal-lease-LXA7MMPO.js → terminal-lease-BNLFA4OF.js} +8 -7
  230. package/dist/{tools-3UB7TEVR.js → tools-7IM6BDCE.js} +12 -12
  231. package/dist/{trace-TAMIU4OJ.js → trace-C3MBGD4S.js} +16 -65
  232. package/dist/{tui-primitives-A6MUW32V.js → tui-primitives-36BY2774.js} +2 -2
  233. package/dist/{uninstall-QYVRPEM4.js → uninstall-WWLOSZ42.js} +35 -10
  234. package/dist/{upgrade-7PMKM2JH.js → upgrade-ETK2JNSJ.js} +42 -51
  235. package/dist/{usage-6EQV7EQK.js → usage-S2HOB7BZ.js} +112 -102
  236. package/dist/{verifiers-JLITWSHU.js → verifiers-QDTEVH7R.js} +26 -24
  237. package/dist/{verify-T7NAEVIG.js → verify-SUKUK6XM.js} +16 -15
  238. package/dist/web/client/THIRD_PARTY_LICENSES.md +1809 -0
  239. package/dist/web/client/assets/abnfDiagram-VCTEODGH-BznNOe_I.js +1 -0
  240. package/dist/web/client/assets/arc-Pry-7G1_.js +1 -0
  241. package/dist/web/client/assets/architecture-7GRP2DOG-BQO9DL_y.js +1 -0
  242. package/dist/web/client/assets/architectureDiagram-5GKGNRK7-CKPbdvyx.js +36 -0
  243. package/dist/web/client/assets/array-BifhSqXX.js +1 -0
  244. package/dist/web/client/assets/atkinson-hyperlegible-next-latin-ext-wght-normal-C6vrW8VD.woff2 +0 -0
  245. package/dist/web/client/assets/atkinson-hyperlegible-next-latin-wght-normal-BcXVPD7q.woff2 +0 -0
  246. package/dist/web/client/assets/blockDiagram-I7D4REHJ-prINbpbM.js +129 -0
  247. package/dist/web/client/assets/c4Diagram-7LVT6UL2-DkVRKtyU.js +38 -0
  248. package/dist/web/client/assets/channel-c4EeUUqA.js +1 -0
  249. package/dist/web/client/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  250. package/dist/web/client/assets/chunk-4HAMMTFA-CV0Z1ApC.js +62 -0
  251. package/dist/web/client/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
  252. package/dist/web/client/assets/chunk-75Z2AOVW-D34Nohxq.js +2 -0
  253. package/dist/web/client/assets/chunk-DU6HZSFF-Das_cS-O.js +125 -0
  254. package/dist/web/client/assets/chunk-F27PBJKO-CmRojxkG.js +1 -0
  255. package/dist/web/client/assets/chunk-FOHPRMQF-CoA4358r.js +161 -0
  256. package/dist/web/client/assets/chunk-GMAD6QVW-ClYZmc73.js +72 -0
  257. package/dist/web/client/assets/chunk-GVQU2GXP-B2BiHFt-.js +1 -0
  258. package/dist/web/client/assets/chunk-IMKFNOWR-BGApZ8nP.js +231 -0
  259. package/dist/web/client/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  260. package/dist/web/client/assets/chunk-L3NEJ4N5-DIzCgpkY.js +1 -0
  261. package/dist/web/client/assets/chunk-OSK3NFVY-BPT-yePv.js +10 -0
  262. package/dist/web/client/assets/chunk-P2QGCYS3-BC1WTc2t.js +1 -0
  263. package/dist/web/client/assets/chunk-POPQ4Y6H-BSjzBmZU.js +1 -0
  264. package/dist/web/client/assets/chunk-PWAF6VOD-BIjLs86Z.js +1 -0
  265. package/dist/web/client/assets/chunk-SHT3W25Y-CduDz2cm.js +168 -0
  266. package/dist/web/client/assets/chunk-SVP7TREG-XUn4pPAP.js +88 -0
  267. package/dist/web/client/assets/chunk-TICWLB2K-DcBy2DKy.js +206 -0
  268. package/dist/web/client/assets/chunk-XXDRQBXY-DqAYeljN.js +1 -0
  269. package/dist/web/client/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  270. package/dist/web/client/assets/classDiagram-ZZMXUADV-C0HR7YKN.js +1 -0
  271. package/dist/web/client/assets/classDiagram-v2-VYDZK3BY-C0HR7YKN.js +1 -0
  272. package/dist/web/client/assets/commit-mono-latin-400-normal-s0S3qwFW.woff +0 -0
  273. package/dist/web/client/assets/commit-mono-latin-400-normal-wzhe4RuD.woff2 +0 -0
  274. package/dist/web/client/assets/cose-bilkent-JH36ORCC-CVh1icwb.js +1 -0
  275. package/dist/web/client/assets/cynefin-OW5HDTMX-BecPbyM6.js +1 -0
  276. package/dist/web/client/assets/cynefinDiagram-5FMLGOSQ-BzMzFwyT.js +62 -0
  277. package/dist/web/client/assets/cytoscape.esm-c2aL46s-.js +321 -0
  278. package/dist/web/client/assets/dagre-C-rnJpZF.js +1 -0
  279. package/dist/web/client/assets/dagre-GXQ25YYZ-CAWJmRMG.js +4 -0
  280. package/dist/web/client/assets/defaultLocale-BFoDCU3G.js +1 -0
  281. package/dist/web/client/assets/diagram-S7CK7UJ4--lp0ALmn.js +30 -0
  282. package/dist/web/client/assets/diagram-UQ7AKVKN-gKUnsjcj.js +41 -0
  283. package/dist/web/client/assets/diagram-VSXAHHWV-BoN5D1Gh.js +3 -0
  284. package/dist/web/client/assets/diagram-VX7I27RA-BMtuswQ6.js +24 -0
  285. package/dist/web/client/assets/diagram-Z3DM3KII-DtU8LXrA.js +24 -0
  286. package/dist/web/client/assets/dist-v5Q1xZ2K.js +1 -0
  287. package/dist/web/client/assets/ebnfDiagram-PWID7BFC-DDcnv9BH.js +1 -0
  288. package/dist/web/client/assets/erDiagram-RLTQ6QDP-DvRb4iDL.js +99 -0
  289. package/dist/web/client/assets/eventmodeling-NTZA5JFV-01h4SbTc.js +1 -0
  290. package/dist/web/client/assets/flowDiagram-HODETNUW-Bll_YZ6T.js +1 -0
  291. package/dist/web/client/assets/framework-YGoR34M4.js +9 -0
  292. package/dist/web/client/assets/ganttDiagram-EL5Y4UJY-DdFZ9hvH.js +292 -0
  293. package/dist/web/client/assets/gitGraph-4MIJSDKK-DjD_AAMj.js +1 -0
  294. package/dist/web/client/assets/gitGraphDiagram-WWUBYQGX-CDyN9n2u.js +106 -0
  295. package/dist/web/client/assets/graphlib-DS17s2tU.js +1 -0
  296. package/dist/web/client/assets/index-CVcy0FAn.js +75 -0
  297. package/dist/web/client/assets/index-Dsi52apB.css +1 -0
  298. package/dist/web/client/assets/info-A6RAGUB7-C_XK8Hq0.js +1 -0
  299. package/dist/web/client/assets/infoDiagram-27XIBGKW-DIe4tJ1i.js +2 -0
  300. package/dist/web/client/assets/init-C-OQMol4.js +1 -0
  301. package/dist/web/client/assets/ishikawaDiagram-5VMMS53U-CVl5unKI.js +70 -0
  302. package/dist/web/client/assets/journeyDiagram-3NMN7TZE-CPEB1Vt8.js +139 -0
  303. package/dist/web/client/assets/kanban-definition-UXKFOSKX-j-9WXjYQ.js +89 -0
  304. package/dist/web/client/assets/katex-ZlcWpGUi.js +257 -0
  305. package/dist/web/client/assets/line-BIDAcEtX.js +1 -0
  306. package/dist/web/client/assets/linear-SzVmGSw4.js +1 -0
  307. package/dist/web/client/assets/mermaid-parser.core-Ux4vssh0.js +7 -0
  308. package/dist/web/client/assets/mermaid.core-CDuwVKeh.js +44 -0
  309. package/dist/web/client/assets/mindmap-definition-YA3MSWOX-5MlQEeQ6.js +96 -0
  310. package/dist/web/client/assets/newsreader-latin-ext-wght-normal-C-3rgBeH.woff2 +0 -0
  311. package/dist/web/client/assets/newsreader-latin-wght-normal-CCVVNp6i.woff2 +0 -0
  312. package/dist/web/client/assets/newsreader-vietnamese-wght-normal-Czsa-EzN.woff2 +0 -0
  313. package/dist/web/client/assets/ordinal-BDEzSJ7C.js +1 -0
  314. package/dist/web/client/assets/packet-AYTQ26CC-DRO66c9Q.js +1 -0
  315. package/dist/web/client/assets/path-fybaL0A-.js +1 -0
  316. package/dist/web/client/assets/pegDiagram-XKGWAZYB-BakZnSjM.js +1 -0
  317. package/dist/web/client/assets/pie-WAS4IAKB-BEzcmhz8.js +1 -0
  318. package/dist/web/client/assets/pieDiagram-E7YTZNPT-DpmqgoPt.js +39 -0
  319. package/dist/web/client/assets/prism-bash-D6zCJ74D.js +1 -0
  320. package/dist/web/client/assets/prism-c-04YixN25.js +1 -0
  321. package/dist/web/client/assets/prism-clike-DapgWyxx.js +1 -0
  322. package/dist/web/client/assets/prism-core-BtsZdCS6.js +1 -0
  323. package/dist/web/client/assets/prism-cpp-C-lJbC-6.js +1 -0
  324. package/dist/web/client/assets/prism-css-CPgOzxXp.js +1 -0
  325. package/dist/web/client/assets/prism-diff-BF8m0_mq.js +3 -0
  326. package/dist/web/client/assets/prism-docker-DkT6yOFj.js +1 -0
  327. package/dist/web/client/assets/prism-fortran-Be5x3y1V.js +1 -0
  328. package/dist/web/client/assets/prism-go-C_8qAH5n.js +1 -0
  329. package/dist/web/client/assets/prism-ini-BESK3y0r.js +1 -0
  330. package/dist/web/client/assets/prism-javascript-BnO-swvr.js +1 -0
  331. package/dist/web/client/assets/prism-json-Dp_-W-Hv.js +1 -0
  332. package/dist/web/client/assets/prism-jsx-D-D0NWtC.js +1 -0
  333. package/dist/web/client/assets/prism-julia-DIjOgiAV.js +1 -0
  334. package/dist/web/client/assets/prism-latex-DNMbqcH_.js +1 -0
  335. package/dist/web/client/assets/prism-makefile-CRKWLQ8l.js +1 -0
  336. package/dist/web/client/assets/prism-markdown-C0FPJ1Iz.js +1 -0
  337. package/dist/web/client/assets/prism-markup-Cp04rIa1.js +1 -0
  338. package/dist/web/client/assets/prism-matlab-D-nk08al.js +1 -0
  339. package/dist/web/client/assets/prism-python-CfiSVtM6.js +1 -0
  340. package/dist/web/client/assets/prism-r-QmNGR8LX.js +1 -0
  341. package/dist/web/client/assets/prism-rust-Bu9N8X3N.js +1 -0
  342. package/dist/web/client/assets/prism-shell-session-Be4UuYoM.js +1 -0
  343. package/dist/web/client/assets/prism-sql-CYhVDMEE.js +1 -0
  344. package/dist/web/client/assets/prism-toml-DKb54GAT.js +1 -0
  345. package/dist/web/client/assets/prism-tsx-p6J2Kc_4.js +1 -0
  346. package/dist/web/client/assets/prism-typescript-BMqONzxf.js +1 -0
  347. package/dist/web/client/assets/prism-yaml-C0JHu8gr.js +1 -0
  348. package/dist/web/client/assets/purify.es-ChwZkWde.js +3 -0
  349. package/dist/web/client/assets/quadrantDiagram-AXDQQJYC-DuMPwwV2.js +7 -0
  350. package/dist/web/client/assets/radar-RG4KPBEZ-Djm3oXl5.js +1 -0
  351. package/dist/web/client/assets/railroad-74A4TZTK-Cpvkwsao.js +1 -0
  352. package/dist/web/client/assets/railroad-abnf-HS5TGJTU-CpRQ3ruG.js +1 -0
  353. package/dist/web/client/assets/railroad-ebnf-LZEXJU2U-1Rm5a5eJ.js +1 -0
  354. package/dist/web/client/assets/railroad-peg-WCYAUIDC-C8344cTh.js +1 -0
  355. package/dist/web/client/assets/railroadDiagram-O6MQD6OU-CgMS4B6R.js +1 -0
  356. package/dist/web/client/assets/requirementDiagram-BXWQKSXE-CX5eoNdN.js +84 -0
  357. package/dist/web/client/assets/rolldown-runtime-hePW80VL.js +1 -0
  358. package/dist/web/client/assets/rough.esm-Dy-Kn_BL.js +1 -0
  359. package/dist/web/client/assets/sankeyDiagram-P5KCCOFB-CODBX2N3.js +40 -0
  360. package/dist/web/client/assets/sequenceDiagram-WJ2MYXX4-eUhhF8OR.js +162 -0
  361. package/dist/web/client/assets/sizeCapture-INFHLROL-B0uUizjq.js +1 -0
  362. package/dist/web/client/assets/src-B6xuSHsQ.js +1 -0
  363. package/dist/web/client/assets/stateDiagram-D77RDMKH-vR6l0NC2.js +1 -0
  364. package/dist/web/client/assets/stateDiagram-v2-MP3YSRHH-BYUm8jLY.js +1 -0
  365. package/dist/web/client/assets/swimlanes-42K2YHIH-v9Tw_zX7.js +1 -0
  366. package/dist/web/client/assets/swimlanesDiagram-VR7AAH4N-B2jdCvhD.js +8 -0
  367. package/dist/web/client/assets/timeline-definition-24CTP7MA-DxianbhU.js +120 -0
  368. package/dist/web/client/assets/treeView-Q6P3EWNA-DLxnZb9R.js +1 -0
  369. package/dist/web/client/assets/treemap-WGGIJYW6-I7UnZ6xJ.js +1 -0
  370. package/dist/web/client/assets/vennDiagram-4TSXK5OY-Ar7M8Mrj.js +34 -0
  371. package/dist/web/client/assets/wardley-WFR3VGLG-B8ZSHeDu.js +1 -0
  372. package/dist/web/client/assets/wardleyDiagram-VM6X3IG4-Qks2FmIn.js +78 -0
  373. package/dist/web/client/assets/xychartDiagram-S5SC5T6Z-BBBjRtiE.js +7 -0
  374. package/dist/web/client/clio-coder-logo.webp +0 -0
  375. package/dist/web/client/icon-192.png +0 -0
  376. package/dist/web/client/icon-512.png +0 -0
  377. package/dist/web/client/index.html +6 -0
  378. package/dist/web/client/manifest.webmanifest +15 -0
  379. package/dist/web/client/offline.css +55 -0
  380. package/dist/web/client/offline.html +5 -0
  381. package/dist/web/client/offline.js +27 -0
  382. package/dist/web/client/sw.js +34 -0
  383. package/dist/web/ops-worker.js +37 -0
  384. package/dist/web/reads-worker.js +1726 -0
  385. package/dist/web/server.js +8499 -0
  386. package/dist/web-EMGUGGEI.js +13 -0
  387. package/dist/{web-fetch-W4TNW4Q7.js → web-fetch-6BRRVQON.js} +22 -5
  388. package/dist/{wiki-generate-T2TJQJUA.js → wiki-generate-XHSJTDOP.js} +120 -113
  389. package/dist/{with-panes-CHFC7HGI.js → with-panes-Z6BTEHMZ.js} +12 -12
  390. package/dist/worker/entry.js +113 -99
  391. package/docs/README.md +28 -27
  392. package/docs/architecture/acp.md +5 -9
  393. package/docs/architecture/alcf-provider.md +0 -3
  394. package/docs/architecture/architecture.md +0 -3
  395. package/docs/architecture/artifact-placement.md +12 -4
  396. package/docs/architecture/artifact-versions.md +0 -3
  397. package/docs/architecture/capacity-and-scheduling.md +0 -3
  398. package/docs/architecture/context-engine.md +0 -3
  399. package/docs/architecture/context-working-set.md +0 -3
  400. package/docs/architecture/dispatch-architecture-rationale.md +0 -3
  401. package/docs/architecture/dispatch-typed-intent.md +0 -3
  402. package/docs/architecture/evidence-and-memory.md +0 -3
  403. package/docs/architecture/library.md +1 -3
  404. package/docs/architecture/middleware-and-components.md +0 -3
  405. package/docs/architecture/model-catalog.md +1 -4
  406. package/docs/architecture/observability.md +0 -3
  407. package/docs/architecture/pi-boundary.md +6 -9
  408. package/docs/architecture/prompt-envelope-and-tools.md +37 -30
  409. package/docs/architecture/provider-adapter-cookbook.md +1 -4
  410. package/docs/architecture/safety-model.md +19 -9
  411. package/docs/architecture/session-lifecycle.md +10 -7
  412. package/docs/architecture/time-conventions.md +0 -3
  413. package/docs/architecture/trace-store.md +28 -20
  414. package/docs/architecture/tui-design.md +38 -18
  415. package/docs/architecture/worker-context.md +1 -3
  416. package/docs/architecture/worker-dispatch-mechanics.md +1 -4
  417. package/docs/guide/authoring-plugins.md +1 -3
  418. package/docs/guide/built-in-agents.md +0 -3
  419. package/docs/guide/commands-and-modes.md +41 -25
  420. package/docs/guide/configuration-and-targets.md +204 -9
  421. package/docs/guide/configuration-reference.md +125 -17
  422. package/docs/guide/environment-variables.md +2 -8
  423. package/docs/guide/exit-codes-and-output.md +0 -3
  424. package/docs/guide/extensions-and-sharing.md +0 -3
  425. package/docs/guide/fleet-dispatch.md +3 -5
  426. package/docs/guide/glossary.md +1 -4
  427. package/docs/guide/harness-extensions.md +0 -2
  428. package/docs/guide/installation-and-lifecycle.md +3 -6
  429. package/docs/guide/interop.md +0 -2
  430. package/docs/guide/panes-and-files.md +0 -3
  431. package/docs/guide/plugins.md +0 -3
  432. package/docs/guide/proactive-memory.md +0 -3
  433. package/docs/guide/resource-library.md +1 -3
  434. package/docs/guide/skills-marketplace.md +0 -2
  435. package/docs/guide/tool-usage.md +166 -67
  436. package/docs/guide/troubleshooting.md +1 -4
  437. package/docs/history/config-knobs-audit.md +0 -3
  438. package/docs/history/release-cut-checklist.md +0 -3
  439. package/docs/process/development-pipeline.md +0 -3
  440. package/docs/process/documentation-coverage.md +3 -3
  441. package/docs/process/documentation-guide.md +16 -22
  442. package/docs/process/eval-runner.md +0 -3
  443. package/docs/process/evals-internal.md +0 -3
  444. package/docs/process/evolution.md +0 -3
  445. package/docs/process/fleet-demo-runbook.md +6 -9
  446. package/docs/process/git-commit-provenance.md +0 -3
  447. package/docs/process/performance-methodology.md +1 -4
  448. package/docs/process/release-cut-checklist.md +114 -221
  449. package/docs/process/scientific-validation.md +23 -6
  450. package/docs/process/tool-audit-v0.4.9.md +357 -0
  451. package/library/registry.yaml +2 -2
  452. package/library/skills/meta/clio-coder-test/SKILL.md +25 -15
  453. package/library/skills/meta/clio-coder-test/evals.md +16 -2
  454. package/library/skills/meta/clio-coder-test/plugin.json +1 -1
  455. package/library/skills/meta/clio-coder-test/references/test-map.md +19 -18
  456. package/library/skills/registry.yaml +2 -2
  457. package/library/skills/skill-marketplace.json +1 -1
  458. package/package.json +13 -11
  459. package/src/cli/argv.ts +31 -0
  460. package/src/cli/clio.ts +17 -13
  461. package/src/cli/config.ts +4 -0
  462. package/src/cli/docs.ts +65 -328
  463. package/src/cli/doctor-panes.ts +1 -1
  464. package/src/cli/doctor.ts +3 -1
  465. package/src/cli/index.ts +17 -2
  466. package/src/cli/mcp.ts +106 -0
  467. package/src/cli/skills-eval.ts +8 -2
  468. package/src/cli/trace.ts +4 -65
  469. package/src/cli/uninstall.ts +26 -0
  470. package/src/cli/upgrade.ts +34 -38
  471. package/src/cli/usage.ts +3 -0
  472. package/src/cli/verifiers.ts +1 -1
  473. package/src/cli/web.ts +79 -0
  474. package/src/core/bash-exec.ts +27 -4
  475. package/src/core/bus-events.ts +3 -4
  476. package/src/core/config.ts +73 -1
  477. package/src/core/defaults.ts +10 -1
  478. package/src/core/domain-loader.ts +37 -28
  479. package/src/core/event-bus.ts +1 -1
  480. package/src/core/run-records.ts +438 -0
  481. package/src/core/safe-exec.ts +506 -56
  482. package/src/core/skill-activation.ts +5 -3
  483. package/src/core/termination.ts +16 -12
  484. package/src/core/tool-names.ts +33 -12
  485. package/src/domains/agents/contract.ts +1 -1
  486. package/src/domains/agents/extension.ts +18 -10
  487. package/src/domains/config/extension.ts +5 -4
  488. package/src/domains/context/clio-md.ts +1 -1
  489. package/src/domains/context/worker/pressure.ts +6 -2
  490. package/src/domains/context/working-set/path-index.ts +7 -2
  491. package/src/domains/dispatch/code-step.ts +7 -2
  492. package/src/domains/dispatch/contract.ts +7 -0
  493. package/src/domains/dispatch/execution-role.ts +3 -3
  494. package/src/domains/dispatch/execution-scheduler.ts +204 -79
  495. package/src/domains/dispatch/extension.ts +206 -26
  496. package/src/domains/dispatch/fleet-preflight.ts +18 -3
  497. package/src/domains/dispatch/fleet-run.ts +1 -0
  498. package/src/domains/dispatch/gate-decisions.ts +3 -3
  499. package/src/domains/dispatch/heartbeat.ts +1 -1
  500. package/src/domains/dispatch/host-verification.ts +16 -14
  501. package/src/domains/dispatch/index.ts +1 -0
  502. package/src/domains/dispatch/orphan-recovery.ts +1 -0
  503. package/src/domains/dispatch/receipt-findings.ts +3 -4
  504. package/src/domains/dispatch/receipt-integrity.ts +3 -0
  505. package/src/domains/dispatch/reservation-store.ts +7 -9
  506. package/src/domains/dispatch/route-facts.ts +1 -1
  507. package/src/domains/dispatch/state.ts +4 -5
  508. package/src/domains/dispatch/types.ts +3 -1
  509. package/src/domains/eval/metrics/tracked.ts +22 -2
  510. package/src/domains/evidence/build.ts +35 -7
  511. package/src/domains/extensions/operator-runtime.ts +3 -1
  512. package/src/domains/gateway/mcp/client.ts +923 -0
  513. package/src/domains/gateway/mcp/config.ts +456 -0
  514. package/src/domains/gateway/mcp/index.ts +88 -0
  515. package/src/domains/gateway/mcp/protocol.ts +273 -0
  516. package/src/domains/gateway/mcp/trust.ts +263 -0
  517. package/src/domains/lifecycle/doctor.ts +17 -3
  518. package/src/domains/middleware/hooks.ts +2 -2
  519. package/src/domains/mux/contract.ts +5 -9
  520. package/src/domains/mux/detect.ts +1 -1
  521. package/src/domains/mux/extension.ts +1 -1
  522. package/src/domains/mux/protocol.ts +5 -7
  523. package/src/domains/mux/socket-client.ts +3 -3
  524. package/src/domains/observability/accountability.ts +2 -2
  525. package/src/domains/observability/background-memory-usage.ts +3 -0
  526. package/src/domains/observability/compaction-usage.ts +2 -0
  527. package/src/domains/observability/contract.ts +7 -3
  528. package/src/domains/observability/cost.ts +5 -0
  529. package/src/domains/observability/evidence-index.ts +2 -2
  530. package/src/domains/observability/extension.ts +1 -0
  531. package/src/domains/observability/out-of-turn-usage.ts +2 -0
  532. package/src/domains/observability/projection.ts +10 -0
  533. package/src/domains/observability/trace-store.ts +65 -5
  534. package/src/domains/prompts/compiler.ts +41 -23
  535. package/src/domains/prompts/extension.ts +4 -17
  536. package/src/domains/prompts/fragments/identity/docs-routing.md +2 -2
  537. package/src/domains/prompts/fragments/operating/skills.md +12 -10
  538. package/src/domains/providers/cache-deployment.ts +147 -0
  539. package/src/domains/providers/catalog.ts +12 -7
  540. package/src/domains/providers/extension.ts +27 -5
  541. package/src/domains/providers/index.ts +6 -1
  542. package/src/domains/providers/models/local-models/clio-coder-local-coding-targets.yaml +42 -10
  543. package/src/domains/providers/plugins.ts +3 -13
  544. package/src/domains/providers/probe/http.ts +44 -59
  545. package/src/domains/providers/probe/reasoning.ts +2 -0
  546. package/src/domains/providers/runtimes/common/local-synth.ts +4 -0
  547. package/src/domains/providers/runtimes/local-native/llamacpp-embed.ts +20 -31
  548. package/src/domains/providers/runtimes/local-native/llamacpp-rerank.ts +9 -4
  549. package/src/domains/providers/types/target-descriptor.ts +17 -0
  550. package/src/domains/safety/action-classifier.ts +17 -1
  551. package/src/domains/safety/call-target.ts +14 -0
  552. package/src/domains/safety/contract.ts +1 -1
  553. package/src/domains/safety/finish-contract.ts +9 -3
  554. package/src/domains/safety/loop-detector.ts +1 -1
  555. package/src/domains/safety/policy-engine.ts +7 -0
  556. package/src/domains/safety/protected-artifacts.ts +3 -4
  557. package/src/domains/safety/rejection-feedback.ts +1 -1
  558. package/src/domains/safety/scope.ts +2 -3
  559. package/src/domains/safety/validation-contract.ts +3 -2
  560. package/src/domains/scheduling/budget.ts +5 -3
  561. package/src/domains/scheduling/contract.ts +2 -1
  562. package/src/domains/scheduling/extension.ts +3 -3
  563. package/src/domains/session/compaction/branch-summary.ts +1 -1
  564. package/src/domains/session/compaction/compact.ts +29 -3
  565. package/src/domains/session/compaction/cut-point.ts +1 -1
  566. package/src/domains/session/compaction/tokens.ts +5 -10
  567. package/src/domains/session/contract.ts +1 -1
  568. package/src/domains/session/cwd-fallback.ts +2 -2
  569. package/src/domains/session/entries.ts +1 -0
  570. package/src/domains/session/handoff.ts +5 -1
  571. package/src/domains/session/history.ts +6 -0
  572. package/src/domains/session/manager.ts +14 -7
  573. package/src/domains/session/retry.ts +2 -1
  574. package/src/domains/session/session-artifacts.ts +12 -7
  575. package/src/domains/session/task-board.ts +2 -3
  576. package/src/domains/session/usage.ts +6 -7
  577. package/src/engine/acp/server.ts +11 -0
  578. package/src/engine/ai.ts +2 -0
  579. package/src/engine/apis/openai-completions.ts +17 -4
  580. package/src/engine/loop-guard.ts +7 -0
  581. package/src/engine/prewarm.ts +232 -0
  582. package/src/engine/provider-diagnostics.ts +6 -1
  583. package/src/engine/provider-error-body.ts +65 -0
  584. package/src/engine/session.ts +118 -29
  585. package/src/engine/worker-runtime.ts +3 -0
  586. package/src/entry/boot-options.ts +2 -0
  587. package/src/entry/orchestrator.ts +38 -18
  588. package/src/interactive/chat-loop-messages.ts +3 -0
  589. package/src/interactive/chat-loop-policy.ts +1 -0
  590. package/src/interactive/chat-loop.ts +10 -12
  591. package/src/interactive/chat-panel.ts +23 -9
  592. package/src/interactive/chat-renderer.ts +33 -11
  593. package/src/interactive/clio-editor.ts +13 -5
  594. package/src/interactive/dispatch-board.ts +70 -30
  595. package/src/interactive/editor-submit.ts +30 -25
  596. package/src/interactive/footer/widgets.ts +12 -9
  597. package/src/interactive/interactive-presentation.ts +2 -3
  598. package/src/interactive/mux-bridge.ts +3 -7
  599. package/src/interactive/overlay-general-openers.ts +14 -7
  600. package/src/interactive/overlays/cwd-fallback.ts +1 -1
  601. package/src/interactive/overlays/library-model.ts +114 -35
  602. package/src/interactive/overlays/library.ts +52 -5
  603. package/src/interactive/overlays/list-overlay.ts +4 -1
  604. package/src/interactive/overlays/session-selector.ts +28 -23
  605. package/src/interactive/overlays/settings.ts +20 -1
  606. package/src/interactive/overlays/tree-selector.ts +47 -10
  607. package/src/interactive/panes-runtime.ts +1 -1
  608. package/src/interactive/prewarm.ts +11 -197
  609. package/src/interactive/renderers/compaction-summary.ts +1 -1
  610. package/src/interactive/renderers/provider-error.ts +118 -0
  611. package/src/interactive/renderers/retry-status.ts +59 -23
  612. package/src/interactive/renderers/tool-execution.ts +67 -7
  613. package/src/interactive/renderers/worker-answer.ts +198 -0
  614. package/src/interactive/renderers/worker-entry.ts +57 -163
  615. package/src/interactive/session-usage-reseed.ts +2 -0
  616. package/src/interactive/side-question.ts +2 -0
  617. package/src/interactive/slash-commands.ts +26 -1
  618. package/src/interactive/slash-spec.ts +2 -2
  619. package/src/interactive/theme/labels.ts +66 -30
  620. package/src/interactive/turn-context.ts +1 -0
  621. package/src/interactive/turn-persistence.ts +9 -1
  622. package/src/interactive/turn-prewarm.ts +126 -19
  623. package/src/interactive/turn-recovery.ts +2 -1
  624. package/src/interactive/turn-runtime.ts +36 -5
  625. package/src/interactive/view/artifacts.ts +3 -2
  626. package/src/interactive/view/view-overlay.ts +96 -20
  627. package/src/tools/agent-tools.ts +21 -7
  628. package/src/tools/artifact.ts +16 -8
  629. package/src/tools/bash.ts +90 -11
  630. package/src/tools/bootstrap.ts +42 -4
  631. package/src/tools/builtin-tool-catalog.ts +80 -11
  632. package/src/tools/context/index.ts +27 -31
  633. package/src/tools/context/library.ts +3 -1
  634. package/src/tools/context/surface.ts +12 -26
  635. package/src/tools/core-bootstrap.ts +72 -1
  636. package/src/tools/data/csv.ts +1189 -0
  637. package/src/tools/data/index.ts +308 -0
  638. package/src/tools/data/json.ts +1799 -0
  639. package/src/tools/data/jsonl.ts +561 -0
  640. package/src/tools/data/shared.ts +452 -0
  641. package/src/tools/edit-diff.ts +0 -7
  642. package/src/tools/edit.ts +115 -18
  643. package/src/tools/file-mutation-queue.ts +114 -4
  644. package/src/tools/find.ts +108 -29
  645. package/src/tools/gateway/caps.ts +11 -0
  646. package/src/tools/gateway/clio-context-surface.ts +41 -0
  647. package/src/tools/gateway/clio-context-tools.ts +77 -0
  648. package/src/tools/gateway/data-surface.ts +138 -0
  649. package/src/tools/gateway/data-tool.ts +201 -0
  650. package/src/tools/gateway/index.ts +342 -0
  651. package/src/tools/gateway/mcp-capabilities.ts +469 -0
  652. package/src/tools/grep.ts +88 -33
  653. package/src/tools/harness-extensions.ts +3 -0
  654. package/src/tools/ignore-policy.ts +7 -5
  655. package/src/tools/ls.ts +111 -20
  656. package/src/tools/policy.ts +35 -13
  657. package/src/tools/presentation.ts +6 -0
  658. package/src/tools/read.ts +634 -156
  659. package/src/tools/registry.ts +106 -8
  660. package/src/tools/run-script.ts +997 -0
  661. package/src/tools/spawn-hygiene.ts +157 -5
  662. package/src/tools/surface.ts +163 -0
  663. package/src/tools/verify/authoring.ts +8 -3
  664. package/src/tools/verify/catalog.ts +14 -1
  665. package/src/tools/verify/numeric.ts +367 -59
  666. package/src/tools/verify/perf.ts +171 -9
  667. package/src/tools/verify/scripts.ts +178 -26
  668. package/src/tools/web-fetch-surface.ts +22 -0
  669. package/src/tools/web-fetch.ts +26 -1
  670. package/src/tools/write.ts +45 -19
  671. package/src/worker/spec-contract.ts +27 -0
  672. package/dist/chunk-B6UM3OZC.js +0 -15
  673. package/dist/chunk-GJ24ODAX.js +0 -196
  674. package/dist/chunk-HRAKUPIH.js +0 -57
  675. package/dist/docs-BL7ROUFN.js +0 -292
@@ -0,0 +1,1726 @@
1
+ import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
+ import {
3
+ readEvidenceIndex
4
+ } from "../chunk-G5R53COU.js";
5
+ import {
6
+ TRACE_SCHEMA_VERSION,
7
+ TraceReader,
8
+ resolveTraceRetentionPolicy,
9
+ traceDatabasePath
10
+ } from "../chunk-GM4TY6VN.js";
11
+ import {
12
+ Id
13
+ } from "../chunk-KKRXONXG.js";
14
+ import {
15
+ runtimeInfo,
16
+ serveWorker,
17
+ toolchainAdapter
18
+ } from "../chunk-JOL2QRLE.js";
19
+ import "../chunk-32KJPXAM.js";
20
+ import "../chunk-5GZICIYO.js";
21
+ import {
22
+ restrictNetwork
23
+ } from "../chunk-AUHVBIDW.js";
24
+ import {
25
+ AppProblem
26
+ } from "../chunk-MZDPF35R.js";
27
+ import "../chunk-XCUDZQLX.js";
28
+ import "../chunk-K2BLQC5E.js";
29
+ import {
30
+ listSessionsForCwd
31
+ } from "../chunk-2VBWFXYE.js";
32
+ import "../chunk-NBPA5QM6.js";
33
+ import "../chunk-EM2WNQS2.js";
34
+ import "../chunk-O3VV6IVK.js";
35
+ import "../chunk-DVJL77SO.js";
36
+ import "../chunk-3RDHGNU7.js";
37
+ import "../chunk-UHW5V7HC.js";
38
+ import "../chunk-KMF54VH3.js";
39
+ import {
40
+ value_exports
41
+ } from "../chunk-SER7RRAE.js";
42
+ import {
43
+ typebox_exports
44
+ } from "../chunk-GH5ZR6JP.js";
45
+ import "../chunk-TK2BMCBZ.js";
46
+ import {
47
+ clioStateDir
48
+ } from "../chunk-CTTI7G3T.js";
49
+ import "../chunk-ZZFWWYLX.js";
50
+ import {
51
+ resolvePackageRoot
52
+ } from "../chunk-E3LEPLQ2.js";
53
+ import {
54
+ init_esm_shims
55
+ } from "../chunk-ECBHH7LU.js";
56
+
57
+ // apps/clio-coder-web/server/worker/reads-main.ts
58
+ init_esm_shims();
59
+ import { workerData } from "node:worker_threads";
60
+
61
+ // apps/clio-coder-web/server/clio/adapters/docs.ts
62
+ init_esm_shims();
63
+ import { readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
64
+ import { dirname, isAbsolute, posix, relative, resolve } from "node:path";
65
+
66
+ // node_modules/.pnpm/marked@18.0.11/node_modules/marked/lib/marked.esm.js
67
+ init_esm_shims();
68
+ function A() {
69
+ return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
70
+ }
71
+ var R = A();
72
+ function j(l3) {
73
+ R = l3;
74
+ }
75
+ var z = { exec: () => null };
76
+ function I(l3) {
77
+ let e = [];
78
+ return (t) => {
79
+ let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
80
+ return s || (s = l3(n), e[n] = s), s;
81
+ };
82
+ }
83
+ function k(l3, e = "") {
84
+ let t = typeof l3 == "string" ? l3 : l3.source, n = { replace: (s, r) => {
85
+ let i = typeof r == "string" ? r : r.source;
86
+ return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
87
+ }, getRegex: () => new RegExp(t, e) };
88
+ return n;
89
+ }
90
+ var Oe = ((l3 = "") => {
91
+ try {
92
+ return !!new RegExp("(?<=1)(?<!1)" + l3);
93
+ } catch {
94
+ return false;
95
+ }
96
+ })();
97
+ var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: I((l3) => new RegExp(`^ {0,${l3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: I((l3) => new RegExp(`^ {0,${l3}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: I((l3) => new RegExp(`^ {0,${l3}}(?:\`\`\`|~~~)`)), headingBeginRegex: I((l3) => new RegExp(`^ {0,${l3}}#`)), htmlBeginRegex: I((l3) => new RegExp(`^ {0,${l3}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: I((l3) => new RegExp(`^ {0,${l3}}>`)) };
98
+ var Te = /^(?:[ \t]*(?:\n|$))+/;
99
+ var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
100
+ var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
101
+ var q = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
102
+ var Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
103
+ var U = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
104
+ var oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
105
+ var ae = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
106
+ var Se = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
107
+ var K = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
108
+ var _e = /^[^\n]+/;
109
+ var W = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
110
+ var $e = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", W).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
111
+ var Le = k(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, U).getRegex();
112
+ var Q = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
113
+ var X = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
114
+ var Ee = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", X).replace("tag", Q).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
115
+ var le = (l3) => k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", l3).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
116
+ var ze = le(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
117
+ var Me = le(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
118
+ var Ae = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Me).getRegex();
119
+ var J = { blockquote: Ae, code: we, def: $e, fences: ye, heading: Pe, hr: q, html: Ee, lheading: ae, list: Le, newline: Te, paragraph: ze, table: z, text: _e };
120
+ var se = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
121
+ var Ie = { ...J, lheading: Se, table: se, paragraph: k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex() };
122
+ var Ce = { ...J, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", X).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: z, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(K).replace("hr", q).replace("heading", ` *#{1,6} *[^
123
+ ]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
124
+ var Be = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
125
+ var De = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
126
+ var ue = /^( {2,}|\\)\n(?!\s*$)/;
127
+ var qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
128
+ var _ = /[\p{P}\p{S}]/u;
129
+ var C = /[\s\p{P}\p{S}]/u;
130
+ var v = /[^\s\p{P}\p{S}]/u;
131
+ var ve = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, C).getRegex();
132
+ var He = /[\p{Pi}\p{Ps}"']/u;
133
+ var pe = /(?!~)[\p{P}\p{S}]/u;
134
+ var Ze = /(?!~)[\s\p{P}\p{S}]/u;
135
+ var Ge = /(?:[^\s\p{P}\p{S}]|~)/u;
136
+ var Qe = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Oe ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
137
+ var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
138
+ var Ne = k(ce, "u").replace(/punct/g, _).getRegex();
139
+ var je = k(ce, "u").replace(/punct/g, pe).getRegex();
140
+ var Fe = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
141
+ var Ue = k(Fe, "u").replace(/openQuote/g, He).replace(/punct/g, _).getRegex();
142
+ var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
143
+ var Ke = k(he, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
144
+ var We = k(he, "gu").replace(/notPunctSpace/g, Ge).replace(/punctSpace/g, Ze).replace(/punct/g, pe).getRegex();
145
+ var Xe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
146
+ var Je = k(Xe, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
147
+ var Ve = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
148
+ var Ye = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
149
+ var et = k(Ye, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
150
+ var tt = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _).getRegex();
151
+ var nt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
152
+ var rt = k(nt, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
153
+ var st = k(/\\(punct)/, "gu").replace(/punct/g, _).getRegex();
154
+ var it = k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
155
+ var ot = k(X).replace("(?:-->|$)", "-->").getRegex();
156
+ var at = k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", ot).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
157
+ var G = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
158
+ var lt = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", G).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
159
+ var ke = k(/^!?\[(label)\]\[(ref)\]/).replace("label", G).replace("ref", W).getRegex();
160
+ var de = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex();
161
+ var ut = k("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", de).getRegex();
162
+ var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
163
+ var V = { _backpedal: z, anyPunctuation: st, autolink: it, blockSkip: Qe, br: ue, code: De, del: z, delLDelim: z, delRDelim: z, emStrongLDelim: Ne, emStrongRDelimAst: Ke, emStrongRDelimUnd: Ve, escape: Be, link: lt, nolink: de, punctuation: ve, reflink: ke, reflinkSearch: ut, tag: at, text: qe, url: z };
164
+ var pt = { ...V, emStrongLDelim: Ue, emStrongRDelimAst: Je, emStrongRDelimUnd: et, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", G).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", G).getRegex() };
165
+ var F = { ...V, emStrongRDelimAst: We, emStrongLDelim: je, delLDelim: tt, delRDelim: rt, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: k(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ie).getRegex() };
166
+ var ct = { ...F, br: k(ue).replace("{2,}", "*").getRegex(), text: k(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
167
+ var H = { normal: J, gfm: Ie, pedantic: Ce };
168
+ var B = { normal: V, gfm: F, breaks: ct, pedantic: pt };
169
+ var ht = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
170
+ var ge = (l3) => ht[l3];
171
+ function T(l3, e) {
172
+ if (e) {
173
+ if (m.escapeTest.test(l3)) return l3.replace(m.escapeReplace, ge);
174
+ } else if (m.escapeTestNoEncode.test(l3)) return l3.replace(m.escapeReplaceNoEncode, ge);
175
+ return l3;
176
+ }
177
+ function Y(l3) {
178
+ try {
179
+ l3 = encodeURI(l3).replace(m.percentDecode, "%");
180
+ } catch {
181
+ return null;
182
+ }
183
+ return l3;
184
+ }
185
+ function ee(l3, e) {
186
+ let t = l3.replace(m.findPipe, (r, i, o) => {
187
+ let u = false, a = i;
188
+ for (; --a >= 0 && o[a] === "\\"; ) u = !u;
189
+ return u ? "|" : " |";
190
+ }), n = t.split(m.splitPipe), s = 0;
191
+ if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
192
+ else for (; n.length < e; ) n.push("");
193
+ for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
194
+ return n;
195
+ }
196
+ function $(l3, e, t) {
197
+ let n = l3.length;
198
+ if (n === 0) return "";
199
+ let s = 0;
200
+ for (; s < n; ) {
201
+ let r = l3.charAt(n - s - 1);
202
+ if (r === e && !t) s++;
203
+ else if (r !== e && t) s++;
204
+ else break;
205
+ }
206
+ return l3.slice(0, n - s);
207
+ }
208
+ function te(l3) {
209
+ let e = l3.split(`
210
+ `), t = e.length - 1;
211
+ for (; t >= 0 && m.blankLine.test(e[t]); ) t--;
212
+ return e.length - t <= 2 ? l3 : e.slice(0, t + 1).join(`
213
+ `);
214
+ }
215
+ function fe(l3, e) {
216
+ if (l3.indexOf(e[1]) === -1) return -1;
217
+ let t = 0;
218
+ for (let n = 0; n < l3.length; n++) if (l3[n] === "\\") n++;
219
+ else if (l3[n] === e[0]) t++;
220
+ else if (l3[n] === e[1] && (t--, t < 0)) return n;
221
+ return t > 0 ? -2 : -1;
222
+ }
223
+ function me(l3, e = 0) {
224
+ let t = e, n = "";
225
+ for (let s of l3) if (s === " ") {
226
+ let r = 4 - t % 4;
227
+ n += " ".repeat(r), t += r;
228
+ } else n += s, t++;
229
+ return n;
230
+ }
231
+ function xe(l3, e, t, n, s) {
232
+ let r = e.href, i = e.title || null, o = l3[1].replace(s.other.outputLinkReplace, "$1"), u = l3[0].charAt(0) === "!";
233
+ n.state.inLink = true;
234
+ let a = n.state.linkEmitted, p = n.state.inRawBlock;
235
+ n.state.linkEmitted = false;
236
+ let c = n.inlineTokens(o), h = n.state.linkEmitted;
237
+ if (n.state.linkEmitted = a, n.state.inLink = false, !u) {
238
+ if (h) {
239
+ n.state.inRawBlock = p;
240
+ return;
241
+ }
242
+ n.state.linkEmitted = true;
243
+ }
244
+ return { type: u ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: c };
245
+ }
246
+ function kt(l3, e, t) {
247
+ let n = l3.match(t.other.indentCodeCompensation);
248
+ if (n === null) return e;
249
+ let s = n[1];
250
+ return e.split(`
251
+ `).map((r) => {
252
+ let i = r.match(t.other.beginningSpace);
253
+ if (i === null) return r;
254
+ let [o] = i;
255
+ return o.length >= s.length ? r.slice(s.length) : r;
256
+ }).join(`
257
+ `);
258
+ }
259
+ var y = class {
260
+ options;
261
+ rules;
262
+ lexer;
263
+ constructor(e) {
264
+ this.options = e || R;
265
+ }
266
+ space(e) {
267
+ let t = this.rules.block.newline.exec(e);
268
+ if (t && t[0].length > 0) return { type: "space", raw: t[0] };
269
+ }
270
+ code(e) {
271
+ let t = this.rules.block.code.exec(e);
272
+ if (t) {
273
+ let n = this.options.pedantic ? t[0] : te(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
274
+ return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
275
+ }
276
+ }
277
+ fences(e) {
278
+ let t = this.rules.block.fences.exec(e);
279
+ if (t) {
280
+ let n = t[0], s = kt(n, t[3] || "", this.rules);
281
+ return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
282
+ }
283
+ }
284
+ heading(e) {
285
+ let t = this.rules.block.heading.exec(e);
286
+ if (t) {
287
+ let n = t[2].trim();
288
+ if (this.rules.other.endingHash.test(n)) {
289
+ let s = $(n, "#");
290
+ (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
291
+ }
292
+ return { type: "heading", raw: $(t[0], `
293
+ `), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
294
+ }
295
+ }
296
+ hr(e) {
297
+ let t = this.rules.block.hr.exec(e);
298
+ if (t) return { type: "hr", raw: $(t[0], `
299
+ `) };
300
+ }
301
+ blockquote(e) {
302
+ let t = this.rules.block.blockquote.exec(e);
303
+ if (t) {
304
+ let n = $(t[0], `
305
+ `).split(`
306
+ `), s = "", r = "", i = [];
307
+ for (; n.length > 0; ) {
308
+ let o = false, u = [], a;
309
+ for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) u.push(n[a]), o = true;
310
+ else if (!o) u.push(n[a]);
311
+ else break;
312
+ n = n.slice(a);
313
+ let p = u.join(`
314
+ `), c = p.replace(this.rules.other.blockquoteSetextReplace, `
315
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
316
+ s = s ? `${s}
317
+ ${p}` : p, r = r ? `${r}
318
+ ${c}` : c;
319
+ let h = this.lexer.state.top;
320
+ if (this.lexer.state.top = true, this.lexer.blockTokens(c, i, true), this.lexer.state.top = h, n.length === 0) break;
321
+ let d = i.at(-1);
322
+ if (d?.type === "code") break;
323
+ if (d?.type === "blockquote") {
324
+ let O = d, g = n.join(`
325
+ `), w = O.raw + `
326
+ ` + g.replace(this.rules.other.blockquoteSetextReplace2, ""), E = this.blockquote(w);
327
+ i[i.length - 1] = E, s = `${s}
328
+ ${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
329
+ break;
330
+ } else if (d?.type === "list") {
331
+ let O = d, g = O.raw + `
332
+ ` + n.join(`
333
+ `), w = this.list(g);
334
+ i[i.length - 1] = w, s = s.substring(0, s.length - d.raw.length) + w.raw, r = r.substring(0, r.length - O.raw.length) + w.raw, n = g.substring(i.at(-1).raw.length).split(`
335
+ `);
336
+ continue;
337
+ }
338
+ }
339
+ return { type: "blockquote", raw: s, tokens: i, text: r };
340
+ }
341
+ }
342
+ list(e) {
343
+ let t = this.rules.block.list.exec(e);
344
+ if (t) {
345
+ let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
346
+ n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
347
+ let i = this.rules.other.listItemRegex(n), o = false;
348
+ for (; e; ) {
349
+ let a = false, p = "", c = "";
350
+ if (!(t = i.exec(e)) || this.rules.block.hr.test(e)) break;
351
+ p = t[0], e = e.substring(p.length);
352
+ let h = me(t[2].split(`
353
+ `, 1)[0], t[1].length), d = e.split(`
354
+ `, 1)[0], O = !h.trim(), g = 0;
355
+ if (this.options.pedantic ? (g = 2, c = h.trimStart()) : O ? g = t[1].length + 1 : (g = h.search(this.rules.other.nonSpaceChar), g = g > 4 ? 1 : g, c = h.slice(g), g += t[1].length), O && this.rules.other.blankLine.test(d) && (p += d + `
356
+ `, e = e.substring(d.length + 1), a = true), !a) {
357
+ let w = this.rules.other.nextBulletRegex(g), E = this.rules.other.hrRegex(g), ne = this.rules.other.fencesBeginRegex(g), re = this.rules.other.headingBeginRegex(g), be = this.rules.other.htmlBeginRegex(g), Re = this.rules.other.blockquoteBeginRegex(g);
358
+ for (; e; ) {
359
+ let N = e.split(`
360
+ `, 1)[0], D;
361
+ if (d = N, this.options.pedantic ? (d = d.replace(this.rules.other.listReplaceNesting, " "), D = d) : D = d.replace(this.rules.other.tabCharGlobal, " "), ne.test(d) || re.test(d) || be.test(d) || Re.test(d) || w.test(d) || E.test(d)) break;
362
+ if (D.search(this.rules.other.nonSpaceChar) >= g || !d.trim()) c += `
363
+ ` + D.slice(g);
364
+ else {
365
+ if (O || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(h) || re.test(h) || E.test(h)) break;
366
+ c += `
367
+ ` + d;
368
+ }
369
+ O = !d.trim(), p += N + `
370
+ `, e = e.substring(N.length + 1), h = D.slice(g);
371
+ }
372
+ }
373
+ r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(p) && (o = true)), r.items.push({ type: "list_item", raw: p, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), r.raw += p;
374
+ }
375
+ let u = r.items.at(-1);
376
+ if (u) u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
377
+ else return;
378
+ r.raw = r.raw.trimEnd();
379
+ for (let a of r.items) if (this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []), !r.loose) {
380
+ let p = a.tokens.filter((h) => h.type === "space"), c = p.length > 0 && p.some((h) => this.rules.other.anyLine.test(h.raw));
381
+ r.loose = c;
382
+ }
383
+ for (let a of r.items) {
384
+ let p = a.tokens[0];
385
+ if (a.task && (p?.type === "text" || p?.type === "paragraph")) {
386
+ a.text = a.text.replace(this.rules.other.listReplaceTask, ""), p.raw = p.raw.replace(this.rules.other.listReplaceTask, ""), p.text = p.text.replace(this.rules.other.listReplaceTask, "");
387
+ for (let h = this.lexer.inlineQueue.length - 1; h >= 0; h--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)) {
388
+ this.lexer.inlineQueue[h].src = this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask, "");
389
+ break;
390
+ }
391
+ let c = this.rules.other.listTaskCheckbox.exec(a.raw);
392
+ if (c) {
393
+ let h = { type: "checkbox", raw: c[0] + " ", checked: c[0] !== "[ ]" };
394
+ a.checked = h.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = h.raw + a.tokens[0].raw, a.tokens[0].text = h.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(h)) : a.tokens.unshift({ type: "paragraph", raw: h.raw, text: h.raw, tokens: [h] }) : a.tokens.unshift(h);
395
+ }
396
+ } else a.task && (a.task = false);
397
+ }
398
+ if (r.loose) for (let a of r.items) {
399
+ a.loose = true;
400
+ for (let p of a.tokens) p.type === "text" && (p.type = "paragraph");
401
+ }
402
+ return r;
403
+ }
404
+ }
405
+ html(e) {
406
+ let t = this.rules.block.html.exec(e);
407
+ if (t) {
408
+ let n = te(t[0]);
409
+ return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
410
+ }
411
+ }
412
+ def(e) {
413
+ let t = this.rules.block.def.exec(e);
414
+ if (t) {
415
+ let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
416
+ return { type: "def", tag: n, raw: $(t[0], `
417
+ `), href: s, title: r };
418
+ }
419
+ }
420
+ table(e) {
421
+ let t = this.rules.block.table.exec(e);
422
+ if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
423
+ let n = ee(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
424
+ `) : [], i = { type: "table", raw: $(t[0], `
425
+ `), header: [], align: [], rows: [] };
426
+ if (n.length === s.length) {
427
+ for (let o of s) this.rules.other.tableAlignRight.test(o) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? i.align.push("left") : i.align.push(null);
428
+ for (let o = 0; o < n.length; o++) i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
429
+ for (let o of r) i.rows.push(ee(o, i.header.length).map((u, a) => ({ text: u, tokens: this.lexer.inline(u), header: false, align: i.align[a] })));
430
+ return i;
431
+ }
432
+ }
433
+ lheading(e) {
434
+ let t = this.rules.block.lheading.exec(e);
435
+ if (t) {
436
+ let n = t[1].trim();
437
+ return { type: "heading", raw: $(t[0], `
438
+ `), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
439
+ }
440
+ }
441
+ paragraph(e) {
442
+ let t = this.rules.block.paragraph.exec(e);
443
+ if (t) {
444
+ let n = t[1].charAt(t[1].length - 1) === `
445
+ ` ? t[1].slice(0, -1) : t[1];
446
+ return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
447
+ }
448
+ }
449
+ text(e) {
450
+ let t = this.rules.block.text.exec(e);
451
+ if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
452
+ }
453
+ escape(e) {
454
+ let t = this.rules.inline.escape.exec(e);
455
+ if (t) return { type: "escape", raw: t[0], text: t[1] };
456
+ }
457
+ tag(e) {
458
+ let t = this.rules.inline.tag.exec(e);
459
+ if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
460
+ }
461
+ link(e) {
462
+ let t = this.rules.inline.link.exec(e);
463
+ if (t) {
464
+ let n = t[2].trim();
465
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
466
+ if (!this.rules.other.endAngleBracket.test(n)) return;
467
+ let i = $(n.slice(0, -1), "\\");
468
+ if ((n.length - i.length) % 2 === 0) return;
469
+ } else {
470
+ let i = fe(t[2], "()");
471
+ if (i === -2) return;
472
+ if (i > -1) {
473
+ let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
474
+ t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u).trim(), t[3] = "";
475
+ }
476
+ }
477
+ let s = t[2], r = "";
478
+ if (this.options.pedantic) {
479
+ let i = this.rules.other.pedanticHrefTitle.exec(s);
480
+ i && (s = i[1], r = i[3]);
481
+ } else r = t[3] ? t[3].slice(1, -1) : "";
482
+ return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), xe(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
483
+ }
484
+ }
485
+ reflink(e, t) {
486
+ let n;
487
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
488
+ let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
489
+ if (!r) {
490
+ let i = n[0].charAt(0);
491
+ return { type: "text", raw: i, text: i };
492
+ }
493
+ return xe(n, r, n[0], this.lexer, this.rules);
494
+ }
495
+ }
496
+ emStrong(e, t, n = "") {
497
+ let s = this.rules.inline.emStrongLDelim.exec(e);
498
+ if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
499
+ if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
500
+ let i = [...s[0]].length - 1, o, u, a = i, p = 0, c = s[0][0], h = n === c, d = c === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
501
+ for (d.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = d.exec(t)) !== null; ) {
502
+ if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
503
+ if (u = [...o].length, s[3] || s[4]) {
504
+ a += u;
505
+ continue;
506
+ } else if (s[5] || s[6]) {
507
+ if (i % 3 && !((i + u) % 3)) {
508
+ p += u;
509
+ continue;
510
+ }
511
+ if (h) break;
512
+ }
513
+ if (a -= u, a > 0) continue;
514
+ u = Math.min(u, u + a + p);
515
+ let O = [...s[0]][0].length, g = e.slice(0, i + s.index + O + u);
516
+ if (Math.min(i, u) % 2) {
517
+ let E = g.slice(1, -1);
518
+ return { type: "em", raw: g, text: E, tokens: this.lexer.inlineTokens(E) };
519
+ }
520
+ let w = g.slice(2, -2);
521
+ return { type: "strong", raw: g, text: w, tokens: this.lexer.inlineTokens(w) };
522
+ }
523
+ }
524
+ }
525
+ codespan(e) {
526
+ let t = this.rules.inline.code.exec(e);
527
+ if (t) {
528
+ let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
529
+ return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
530
+ }
531
+ }
532
+ br(e) {
533
+ let t = this.rules.inline.br.exec(e);
534
+ if (t) return { type: "br", raw: t[0] };
535
+ }
536
+ del(e, t, n = "") {
537
+ let s = this.rules.inline.delLDelim.exec(e);
538
+ if (!s) return;
539
+ if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
540
+ let i = [...s[0]].length - 1, o, u, a = i, p = this.rules.inline.delRDelim;
541
+ for (p.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = p.exec(t)) !== null; ) {
542
+ if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (u = [...o].length, u !== i)) continue;
543
+ if (s[3] || s[4]) {
544
+ a += u;
545
+ continue;
546
+ }
547
+ if (a -= u, a > 0) continue;
548
+ u = Math.min(u, u + a);
549
+ let c = [...s[0]][0].length, h = e.slice(0, i + s.index + c + u), d = h.slice(i, -i);
550
+ return { type: "del", raw: h, text: d, tokens: this.lexer.inlineTokens(d) };
551
+ }
552
+ }
553
+ }
554
+ autolink(e) {
555
+ let t = this.rules.inline.autolink.exec(e);
556
+ if (t) {
557
+ let n, s;
558
+ return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
559
+ }
560
+ }
561
+ url(e) {
562
+ let t;
563
+ if (t = this.rules.inline.url.exec(e)) {
564
+ let n, s;
565
+ if (t[2] === "@") n = t[0], s = "mailto:" + n;
566
+ else {
567
+ let r;
568
+ do
569
+ r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
570
+ while (r !== t[0]);
571
+ n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
572
+ }
573
+ return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
574
+ }
575
+ }
576
+ inlineText(e) {
577
+ let t = this.rules.inline.text.exec(e);
578
+ if (t) {
579
+ let n = this.lexer.state.inRawBlock;
580
+ return { type: "text", raw: t[0], text: t[0], escaped: n };
581
+ }
582
+ }
583
+ };
584
+ var x = class l {
585
+ tokens;
586
+ options;
587
+ state;
588
+ inlineQueue;
589
+ tokenizer;
590
+ constructor(e) {
591
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || R, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, top: true };
592
+ let t = { other: m, block: H.normal, inline: B.normal };
593
+ this.options.pedantic ? (t.block = H.pedantic, t.inline = B.pedantic) : this.options.gfm && (t.block = H.gfm, this.options.breaks ? t.inline = B.breaks : t.inline = B.gfm), this.tokenizer.rules = t;
594
+ }
595
+ static get rules() {
596
+ return { block: H, inline: B };
597
+ }
598
+ static lex(e, t) {
599
+ return new l(t).lex(e);
600
+ }
601
+ static lexInline(e, t) {
602
+ return new l(t).inlineTokens(e);
603
+ }
604
+ lex(e) {
605
+ e = e.replace(m.carriageReturn, `
606
+ `), this.blockTokens(e, this.tokens);
607
+ for (let t = 0; t < this.inlineQueue.length; t++) {
608
+ let n = this.inlineQueue[t];
609
+ this.inlineTokens(n.src, n.tokens);
610
+ }
611
+ return this.inlineQueue = [], this.tokens;
612
+ }
613
+ blockTokens(e, t = [], n = false) {
614
+ this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
615
+ let s = 1 / 0;
616
+ for (; e; ) {
617
+ if (e.length < s) s = e.length;
618
+ else {
619
+ this.infiniteLoopError(e.charCodeAt(0));
620
+ break;
621
+ }
622
+ let r;
623
+ if (this.options.extensions?.block?.some((o) => (r = o.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
624
+ if (r = this.tokenizer.space(e)) {
625
+ e = e.substring(r.raw.length);
626
+ let o = t.at(-1);
627
+ r.raw.length === 1 && o !== void 0 ? o.raw += `
628
+ ` : t.push(r);
629
+ continue;
630
+ }
631
+ if (r = this.tokenizer.code(e)) {
632
+ e = e.substring(r.raw.length);
633
+ let o = t.at(-1);
634
+ o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
635
+ `) ? "" : `
636
+ `) + r.raw, o.text += `
637
+ ` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
638
+ continue;
639
+ }
640
+ if (r = this.tokenizer.fences(e)) {
641
+ e = e.substring(r.raw.length), t.push(r);
642
+ continue;
643
+ }
644
+ if (r = this.tokenizer.heading(e)) {
645
+ e = e.substring(r.raw.length), t.push(r);
646
+ continue;
647
+ }
648
+ if (r = this.tokenizer.hr(e)) {
649
+ e = e.substring(r.raw.length), t.push(r);
650
+ continue;
651
+ }
652
+ if (r = this.tokenizer.blockquote(e)) {
653
+ e = e.substring(r.raw.length), t.push(r);
654
+ continue;
655
+ }
656
+ if (r = this.tokenizer.list(e)) {
657
+ e = e.substring(r.raw.length), t.push(r);
658
+ continue;
659
+ }
660
+ if (r = this.tokenizer.html(e)) {
661
+ e = e.substring(r.raw.length), t.push(r);
662
+ continue;
663
+ }
664
+ if (r = this.tokenizer.def(e)) {
665
+ e = e.substring(r.raw.length);
666
+ let o = t.at(-1);
667
+ o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
668
+ `) ? "" : `
669
+ `) + r.raw, o.text += `
670
+ ` + r.raw, this.inlineQueue.at(-1).src = o.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
671
+ continue;
672
+ }
673
+ if (r = this.tokenizer.table(e)) {
674
+ e = e.substring(r.raw.length), t.push(r);
675
+ continue;
676
+ }
677
+ if (r = this.tokenizer.lheading(e)) {
678
+ e = e.substring(r.raw.length), t.push(r);
679
+ continue;
680
+ }
681
+ let i = e;
682
+ if (this.options.extensions?.startBlock) {
683
+ let o = 1 / 0, u = e.slice(1), a;
684
+ this.options.extensions.startBlock.forEach((p) => {
685
+ a = p.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
686
+ }), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
687
+ }
688
+ if (this.state.top && (r = this.tokenizer.paragraph(i))) {
689
+ let o = t.at(-1);
690
+ n && o?.type === "paragraph" ? (o.raw += (o.raw.endsWith(`
691
+ `) ? "" : `
692
+ `) + r.raw, o.text += `
693
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
694
+ continue;
695
+ }
696
+ if (r = this.tokenizer.text(e)) {
697
+ e = e.substring(r.raw.length);
698
+ let o = t.at(-1);
699
+ o?.type === "text" ? (o.raw += (o.raw.endsWith(`
700
+ `) ? "" : `
701
+ `) + r.raw, o.text += `
702
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
703
+ continue;
704
+ }
705
+ if (e) {
706
+ this.infiniteLoopError(e.charCodeAt(0));
707
+ break;
708
+ }
709
+ }
710
+ return this.state.top = true, t;
711
+ }
712
+ inline(e, t = []) {
713
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
714
+ }
715
+ linkInText(e) {
716
+ if (!e.includes("[")) return false;
717
+ let t = this.tokenizer.rules.inline.link;
718
+ for (let n of e.matchAll(this.tokenizer.rules.inline.blockSkip)) if (t.test(n[0]) && e.charAt(n.index - 1) !== "!") return true;
719
+ for (let n of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)) {
720
+ let s = n[0], r = s.lastIndexOf("[");
721
+ if (!(s.charAt(0) === "!" || !Object.hasOwn(this.tokens.links, s.slice(r + 1, -1))) && !(r > 1 && this.linkInText(s.slice(1, r - 1)))) return true;
722
+ }
723
+ return false;
724
+ }
725
+ inlineTokens(e, t = []) {
726
+ this.tokenizer.lexer = this;
727
+ let n = e;
728
+ if (this.tokens.links && e.includes("[")) {
729
+ let o = this.tokenizer.rules.inline.reflinkSearch, u = (a) => {
730
+ let p = a.lastIndexOf("[");
731
+ if (!Object.hasOwn(this.tokens.links, a.slice(p + 1, -1))) return a;
732
+ if (p > 1 && a.charAt(0) !== "!") {
733
+ let c = a.slice(1, p - 1);
734
+ if (this.linkInText(c)) return "[" + c.replace(o, u) + "][" + "a".repeat(a.length - p - 2) + "]";
735
+ }
736
+ return "[" + "a".repeat(a.length - 2) + "]";
737
+ };
738
+ n = n.replace(o, u);
739
+ }
740
+ n = n.replace(this.tokenizer.rules.inline.anyPunctuation, (o) => "+".repeat(o.length)), n = n.replace(this.tokenizer.rules.inline.blockSkip, (o, u, a) => {
741
+ let p = a ? a.length : 0;
742
+ return o.slice(0, p) + "[" + "a".repeat(o.length - p - 2) + "]";
743
+ }), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
744
+ let s = false, r = "", i = 1 / 0;
745
+ for (; e; ) {
746
+ if (e.length < i) i = e.length;
747
+ else {
748
+ this.infiniteLoopError(e.charCodeAt(0));
749
+ break;
750
+ }
751
+ s || (r = ""), s = false;
752
+ let o;
753
+ if (this.options.extensions?.inline?.some((a) => (o = a.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false)) continue;
754
+ if (o = this.tokenizer.escape(e)) {
755
+ e = e.substring(o.raw.length), t.push(o);
756
+ continue;
757
+ }
758
+ if (o = this.tokenizer.tag(e)) {
759
+ e = e.substring(o.raw.length), t.push(o);
760
+ continue;
761
+ }
762
+ if (o = this.tokenizer.link(e)) {
763
+ e = e.substring(o.raw.length), t.push(o);
764
+ continue;
765
+ }
766
+ if (o = this.tokenizer.reflink(e, this.tokens.links)) {
767
+ e = e.substring(o.raw.length);
768
+ let a = t.at(-1);
769
+ o.type === "text" && a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
770
+ continue;
771
+ }
772
+ if (o = this.tokenizer.emStrong(e, n, r)) {
773
+ e = e.substring(o.raw.length), t.push(o);
774
+ continue;
775
+ }
776
+ if (o = this.tokenizer.codespan(e)) {
777
+ e = e.substring(o.raw.length), t.push(o);
778
+ continue;
779
+ }
780
+ if (o = this.tokenizer.br(e)) {
781
+ e = e.substring(o.raw.length), t.push(o);
782
+ continue;
783
+ }
784
+ if (o = this.tokenizer.del(e, n, r)) {
785
+ e = e.substring(o.raw.length), t.push(o);
786
+ continue;
787
+ }
788
+ if (o = this.tokenizer.autolink(e)) {
789
+ e = e.substring(o.raw.length), t.push(o);
790
+ continue;
791
+ }
792
+ if (!this.state.inLink && (o = this.tokenizer.url(e))) {
793
+ e = e.substring(o.raw.length), t.push(o);
794
+ continue;
795
+ }
796
+ let u = e;
797
+ if (this.options.extensions?.startInline) {
798
+ let a = 1 / 0, p = e.slice(1), c;
799
+ this.options.extensions.startInline.forEach((h) => {
800
+ c = h.call({ lexer: this }, p), typeof c == "number" && c >= 0 && (a = Math.min(a, c));
801
+ }), a < 1 / 0 && a >= 0 && (u = e.substring(0, a + 1));
802
+ }
803
+ if (o = this.tokenizer.inlineText(u)) {
804
+ e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (r = o.raw.slice(-1)), s = true;
805
+ let a = t.at(-1);
806
+ a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
807
+ continue;
808
+ }
809
+ if (e) {
810
+ this.infiniteLoopError(e.charCodeAt(0));
811
+ break;
812
+ }
813
+ }
814
+ return t;
815
+ }
816
+ infiniteLoopError(e) {
817
+ let t = "Infinite loop on byte: " + e;
818
+ if (this.options.silent) console.error(t);
819
+ else throw new Error(t);
820
+ }
821
+ };
822
+ var P = class {
823
+ options;
824
+ parser;
825
+ constructor(e) {
826
+ this.options = e || R;
827
+ }
828
+ space(e) {
829
+ return "";
830
+ }
831
+ code({ text: e, lang: t, escaped: n }) {
832
+ let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
833
+ `;
834
+ return s ? '<pre><code class="language-' + T(s) + '">' + (n ? r : T(r, true)) + `</code></pre>
835
+ ` : "<pre><code>" + (n ? r : T(r, true)) + `</code></pre>
836
+ `;
837
+ }
838
+ blockquote({ tokens: e }) {
839
+ return `<blockquote>
840
+ ${this.parser.parse(e)}</blockquote>
841
+ `;
842
+ }
843
+ html({ text: e }) {
844
+ return e;
845
+ }
846
+ def(e) {
847
+ return "";
848
+ }
849
+ heading({ tokens: e, depth: t }) {
850
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
851
+ `;
852
+ }
853
+ hr(e) {
854
+ return `<hr>
855
+ `;
856
+ }
857
+ list(e) {
858
+ let t = e.ordered, n = e.start, s = "";
859
+ for (let o = 0; o < e.items.length; o++) {
860
+ let u = e.items[o];
861
+ s += this.listitem(u);
862
+ }
863
+ let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
864
+ return "<" + r + i + `>
865
+ ` + s + "</" + r + `>
866
+ `;
867
+ }
868
+ listitem(e) {
869
+ return `<li>${this.parser.parse(e.tokens)}</li>
870
+ `;
871
+ }
872
+ checkbox({ checked: e }) {
873
+ return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
874
+ }
875
+ paragraph({ tokens: e }) {
876
+ return `<p>${this.parser.parseInline(e)}</p>
877
+ `;
878
+ }
879
+ table(e) {
880
+ let t = "", n = "";
881
+ for (let r = 0; r < e.header.length; r++) n += this.tablecell(e.header[r]);
882
+ t += this.tablerow({ text: n });
883
+ let s = "";
884
+ for (let r = 0; r < e.rows.length; r++) {
885
+ let i = e.rows[r];
886
+ n = "";
887
+ for (let o = 0; o < i.length; o++) n += this.tablecell(i[o]);
888
+ s += this.tablerow({ text: n });
889
+ }
890
+ return s && (s = `<tbody>${s}</tbody>`), `<table>
891
+ <thead>
892
+ ` + t + `</thead>
893
+ ` + s + `</table>
894
+ `;
895
+ }
896
+ tablerow({ text: e }) {
897
+ return `<tr>
898
+ ${e}</tr>
899
+ `;
900
+ }
901
+ tablecell(e) {
902
+ let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
903
+ return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
904
+ `;
905
+ }
906
+ strong({ tokens: e }) {
907
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
908
+ }
909
+ em({ tokens: e }) {
910
+ return `<em>${this.parser.parseInline(e)}</em>`;
911
+ }
912
+ codespan({ text: e }) {
913
+ return `<code>${T(e, true)}</code>`;
914
+ }
915
+ br(e) {
916
+ return "<br>";
917
+ }
918
+ del({ tokens: e }) {
919
+ return `<del>${this.parser.parseInline(e)}</del>`;
920
+ }
921
+ link({ href: e, title: t, tokens: n }) {
922
+ let s = this.parser.parseInline(n), r = Y(e);
923
+ if (r === null) return s;
924
+ e = r;
925
+ let i = '<a href="' + e + '"';
926
+ return t && (i += ' title="' + T(t) + '"'), i += ">" + s + "</a>", i;
927
+ }
928
+ image({ href: e, title: t, text: n, tokens: s }) {
929
+ s && (n = this.parser.parseInline(s, this.parser.textRenderer));
930
+ let r = Y(e);
931
+ if (r === null) return T(n);
932
+ e = r;
933
+ let i = `<img src="${e}" alt="${T(n)}"`;
934
+ return t && (i += ` title="${T(t)}"`), i += ">", i;
935
+ }
936
+ text(e) {
937
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : T(e.text);
938
+ }
939
+ };
940
+ var L = class {
941
+ strong({ text: e }) {
942
+ return e;
943
+ }
944
+ em({ text: e }) {
945
+ return e;
946
+ }
947
+ codespan({ text: e }) {
948
+ return e;
949
+ }
950
+ del({ text: e }) {
951
+ return e;
952
+ }
953
+ html({ text: e }) {
954
+ return e;
955
+ }
956
+ text({ text: e }) {
957
+ return e;
958
+ }
959
+ link({ text: e }) {
960
+ return "" + e;
961
+ }
962
+ image({ text: e }) {
963
+ return "" + e;
964
+ }
965
+ br() {
966
+ return "";
967
+ }
968
+ checkbox({ raw: e }) {
969
+ return e;
970
+ }
971
+ };
972
+ var b = class l2 {
973
+ options;
974
+ renderer;
975
+ textRenderer;
976
+ constructor(e) {
977
+ this.options = e || R, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L();
978
+ }
979
+ static parse(e, t) {
980
+ return new l2(t).parse(e);
981
+ }
982
+ static parseInline(e, t) {
983
+ return new l2(t).parseInline(e);
984
+ }
985
+ parse(e) {
986
+ this.renderer.parser = this;
987
+ let t = "";
988
+ for (let n = 0; n < e.length; n++) {
989
+ let s = e[n];
990
+ if (this.options.extensions?.renderers?.[s.type]) {
991
+ let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
992
+ if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(i.type)) {
993
+ t += o || "";
994
+ continue;
995
+ }
996
+ }
997
+ let r = s;
998
+ switch (r.type) {
999
+ case "space": {
1000
+ t += this.renderer.space(r);
1001
+ break;
1002
+ }
1003
+ case "hr": {
1004
+ t += this.renderer.hr(r);
1005
+ break;
1006
+ }
1007
+ case "heading": {
1008
+ t += this.renderer.heading(r);
1009
+ break;
1010
+ }
1011
+ case "code": {
1012
+ t += this.renderer.code(r);
1013
+ break;
1014
+ }
1015
+ case "table": {
1016
+ t += this.renderer.table(r);
1017
+ break;
1018
+ }
1019
+ case "blockquote": {
1020
+ t += this.renderer.blockquote(r);
1021
+ break;
1022
+ }
1023
+ case "list": {
1024
+ t += this.renderer.list(r);
1025
+ break;
1026
+ }
1027
+ case "checkbox": {
1028
+ t += this.renderer.checkbox(r);
1029
+ break;
1030
+ }
1031
+ case "html": {
1032
+ t += this.renderer.html(r);
1033
+ break;
1034
+ }
1035
+ case "def": {
1036
+ t += this.renderer.def(r);
1037
+ break;
1038
+ }
1039
+ case "paragraph": {
1040
+ t += this.renderer.paragraph(r);
1041
+ break;
1042
+ }
1043
+ case "text": {
1044
+ t += this.renderer.text(r);
1045
+ break;
1046
+ }
1047
+ default: {
1048
+ let i = 'Token with "' + r.type + '" type was not found.';
1049
+ if (this.options.silent) return console.error(i), "";
1050
+ throw new Error(i);
1051
+ }
1052
+ }
1053
+ }
1054
+ return t;
1055
+ }
1056
+ parseInline(e, t = this.renderer) {
1057
+ this.renderer.parser = this;
1058
+ let n = "";
1059
+ for (let s = 0; s < e.length; s++) {
1060
+ let r = e[s];
1061
+ if (this.options.extensions?.renderers?.[r.type]) {
1062
+ let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
1063
+ if (o !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
1064
+ n += o || "";
1065
+ continue;
1066
+ }
1067
+ }
1068
+ let i = r;
1069
+ switch (i.type) {
1070
+ case "escape": {
1071
+ n += t.text(i);
1072
+ break;
1073
+ }
1074
+ case "html": {
1075
+ n += t.html(i);
1076
+ break;
1077
+ }
1078
+ case "link": {
1079
+ n += t.link(i);
1080
+ break;
1081
+ }
1082
+ case "image": {
1083
+ n += t.image(i);
1084
+ break;
1085
+ }
1086
+ case "checkbox": {
1087
+ n += t.checkbox(i);
1088
+ break;
1089
+ }
1090
+ case "strong": {
1091
+ n += t.strong(i);
1092
+ break;
1093
+ }
1094
+ case "em": {
1095
+ n += t.em(i);
1096
+ break;
1097
+ }
1098
+ case "codespan": {
1099
+ n += t.codespan(i);
1100
+ break;
1101
+ }
1102
+ case "br": {
1103
+ n += t.br(i);
1104
+ break;
1105
+ }
1106
+ case "del": {
1107
+ n += t.del(i);
1108
+ break;
1109
+ }
1110
+ case "text": {
1111
+ n += t.text(i);
1112
+ break;
1113
+ }
1114
+ default: {
1115
+ let o = 'Token with "' + i.type + '" type was not found.';
1116
+ if (this.options.silent) return console.error(o), "";
1117
+ throw new Error(o);
1118
+ }
1119
+ }
1120
+ }
1121
+ return n;
1122
+ }
1123
+ };
1124
+ var S = class {
1125
+ options;
1126
+ block;
1127
+ constructor(e) {
1128
+ this.options = e || R;
1129
+ }
1130
+ static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
1131
+ static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
1132
+ preprocess(e) {
1133
+ return e;
1134
+ }
1135
+ postprocess(e) {
1136
+ return e;
1137
+ }
1138
+ processAllTokens(e) {
1139
+ return e;
1140
+ }
1141
+ emStrongMask(e) {
1142
+ return e;
1143
+ }
1144
+ provideLexer(e = this.block) {
1145
+ return e ? x.lex : x.lexInline;
1146
+ }
1147
+ provideParser(e = this.block) {
1148
+ return e ? b.parse : b.parseInline;
1149
+ }
1150
+ };
1151
+ var Z = class {
1152
+ defaults = A();
1153
+ options = this.setOptions;
1154
+ parse = this.parseMarkdown(true);
1155
+ parseInline = this.parseMarkdown(false);
1156
+ Parser = b;
1157
+ Renderer = P;
1158
+ TextRenderer = L;
1159
+ Lexer = x;
1160
+ Tokenizer = y;
1161
+ Hooks = S;
1162
+ constructor(...e) {
1163
+ this.use(...e);
1164
+ }
1165
+ walkTokens(e, t) {
1166
+ let n = [];
1167
+ for (let s of e) switch (n = n.concat(t.call(this, s)), s.type) {
1168
+ case "table": {
1169
+ let r = s;
1170
+ for (let i of r.header) n = n.concat(this.walkTokens(i.tokens, t));
1171
+ for (let i of r.rows) for (let o of i) n = n.concat(this.walkTokens(o.tokens, t));
1172
+ break;
1173
+ }
1174
+ case "list": {
1175
+ let r = s;
1176
+ n = n.concat(this.walkTokens(r.items, t));
1177
+ break;
1178
+ }
1179
+ default: {
1180
+ let r = s;
1181
+ this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
1182
+ let o = r[i].flat(1 / 0);
1183
+ n = n.concat(this.walkTokens(o, t));
1184
+ }) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
1185
+ }
1186
+ }
1187
+ return n;
1188
+ }
1189
+ use(...e) {
1190
+ let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
1191
+ return e.forEach((n) => {
1192
+ let s = { ...n };
1193
+ if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
1194
+ if (!r.name) throw new Error("extension name required");
1195
+ if ("renderer" in r) {
1196
+ let i = t.renderers[r.name];
1197
+ i ? t.renderers[r.name] = function(...o) {
1198
+ let u = r.renderer.apply(this, o);
1199
+ return u === false && (u = i.apply(this, o)), u;
1200
+ } : t.renderers[r.name] = r.renderer;
1201
+ }
1202
+ if ("tokenizer" in r) {
1203
+ if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
1204
+ let i = t[r.level];
1205
+ i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
1206
+ }
1207
+ "childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
1208
+ }), s.extensions = t), n.renderer) {
1209
+ let r = this.defaults.renderer || new P(this.defaults);
1210
+ for (let i in n.renderer) {
1211
+ if (!(i in r)) throw new Error(`renderer '${i}' does not exist`);
1212
+ if (["options", "parser"].includes(i)) continue;
1213
+ let o = i, u = n.renderer[o], a = r[o];
1214
+ r[o] = (...p) => {
1215
+ let c = u.apply(r, p);
1216
+ return c === false && (c = a.apply(r, p)), c || "";
1217
+ };
1218
+ }
1219
+ s.renderer = r;
1220
+ }
1221
+ if (n.tokenizer) {
1222
+ let r = this.defaults.tokenizer || new y(this.defaults);
1223
+ for (let i in n.tokenizer) {
1224
+ if (!(i in r)) throw new Error(`tokenizer '${i}' does not exist`);
1225
+ if (["options", "rules", "lexer"].includes(i)) continue;
1226
+ let o = i, u = n.tokenizer[o], a = r[o];
1227
+ r[o] = (...p) => {
1228
+ let c = u.apply(r, p);
1229
+ return c === false && (c = a.apply(r, p)), c;
1230
+ };
1231
+ }
1232
+ s.tokenizer = r;
1233
+ }
1234
+ if (n.hooks) {
1235
+ let r = this.defaults.hooks || new S();
1236
+ for (let i in n.hooks) {
1237
+ if (!(i in r)) throw new Error(`hook '${i}' does not exist`);
1238
+ if (["options", "block"].includes(i)) continue;
1239
+ let o = i, u = n.hooks[o], a = r[o];
1240
+ S.passThroughHooks.has(i) ? r[o] = (p) => {
1241
+ if (this.defaults.async && S.passThroughHooksRespectAsync.has(i)) return (async () => {
1242
+ let h = await u.call(r, p);
1243
+ return a.call(r, h);
1244
+ })();
1245
+ let c = u.call(r, p);
1246
+ return a.call(r, c);
1247
+ } : r[o] = (...p) => {
1248
+ if (this.defaults.async) return (async () => {
1249
+ let h = await u.apply(r, p);
1250
+ return h === false && (h = await a.apply(r, p)), h;
1251
+ })();
1252
+ let c = u.apply(r, p);
1253
+ return c === false && (c = a.apply(r, p)), c;
1254
+ };
1255
+ }
1256
+ s.hooks = r;
1257
+ }
1258
+ if (n.walkTokens) {
1259
+ let r = this.defaults.walkTokens, i = n.walkTokens;
1260
+ s.walkTokens = function(o) {
1261
+ let u = [];
1262
+ return u.push(i.call(this, o)), r && (u = u.concat(r.call(this, o))), u;
1263
+ };
1264
+ }
1265
+ this.defaults = { ...this.defaults, ...s };
1266
+ }), this;
1267
+ }
1268
+ setOptions(e) {
1269
+ return this.defaults = { ...this.defaults, ...e }, this;
1270
+ }
1271
+ lexer(e, t) {
1272
+ return x.lex(e, t ?? this.defaults);
1273
+ }
1274
+ parser(e, t) {
1275
+ return b.parse(e, t ?? this.defaults);
1276
+ }
1277
+ parseMarkdown(e) {
1278
+ return (n, s) => {
1279
+ let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
1280
+ if (this.defaults.async === true && r.async === false) return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1281
+ if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
1282
+ if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
1283
+ if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
1284
+ let u = i.hooks ? await i.hooks.preprocess(n) : n, p = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(u, i), c = i.hooks ? await i.hooks.processAllTokens(p) : p;
1285
+ i.walkTokens && await Promise.all(this.walkTokens(c, i.walkTokens));
1286
+ let d = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(c, i);
1287
+ return i.hooks ? await i.hooks.postprocess(d) : d;
1288
+ })().catch(o);
1289
+ try {
1290
+ i.hooks && (n = i.hooks.preprocess(n));
1291
+ let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
1292
+ i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
1293
+ let c = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
1294
+ return i.hooks && (c = i.hooks.postprocess(c)), c;
1295
+ } catch (u) {
1296
+ return o(u);
1297
+ }
1298
+ };
1299
+ }
1300
+ onError(e, t) {
1301
+ return (n) => {
1302
+ if (n.message += `
1303
+ Please report this to https://github.com/markedjs/marked.`, e) {
1304
+ let s = "<p>An error occurred:</p><pre>" + T(n.message + "", true) + "</pre>";
1305
+ return t ? Promise.resolve(s) : s;
1306
+ }
1307
+ if (t) return Promise.reject(n);
1308
+ throw n;
1309
+ };
1310
+ }
1311
+ };
1312
+ var M = new Z();
1313
+ function f(l3, e) {
1314
+ return M.parse(l3, e);
1315
+ }
1316
+ f.options = f.setOptions = function(l3) {
1317
+ return M.setOptions(l3), f.defaults = M.defaults, j(f.defaults), f;
1318
+ };
1319
+ f.getDefaults = A;
1320
+ f.defaults = R;
1321
+ function dt(...l3) {
1322
+ return M.use(...l3), f.defaults = M.defaults, j(f.defaults), f;
1323
+ }
1324
+ f.use = dt;
1325
+ f.walkTokens = function(l3, e) {
1326
+ return M.walkTokens(l3, e);
1327
+ };
1328
+ f.parseInline = M.parseInline;
1329
+ f.Parser = b;
1330
+ f.parser = b.parse;
1331
+ f.Renderer = P;
1332
+ f.TextRenderer = L;
1333
+ f.Lexer = x;
1334
+ f.lexer = x.lex;
1335
+ f.Tokenizer = y;
1336
+ f.Hooks = S;
1337
+ f.parse = f;
1338
+ var nn = f.options;
1339
+ var rn = f.setOptions;
1340
+ var sn = f.walkTokens;
1341
+ var on = f.parseInline;
1342
+ var ln = b.parse;
1343
+ var un = x.lex;
1344
+
1345
+ // apps/clio-coder-web/contracts/docs-headings.ts
1346
+ init_esm_shims();
1347
+ function documentHeadings(tokens) {
1348
+ const ids = /* @__PURE__ */ new Map();
1349
+ const counts = /* @__PURE__ */ new Map();
1350
+ f.walkTokens([...tokens], (token) => {
1351
+ if (token.type !== "heading") return;
1352
+ const text = token.text.replace(/<[^>]*>/g, "").replace(/[`*_~]/g, "");
1353
+ const base = text.toLowerCase().replace(/[^\p{L}\p{N}_\s-]/gu, "").replace(/\s/g, "-");
1354
+ const n = counts.get(base) ?? 0;
1355
+ counts.set(base, n + 1);
1356
+ ids.set(token, n ? `${base}-${n}` : base);
1357
+ });
1358
+ return ids;
1359
+ }
1360
+
1361
+ // apps/clio-coder-web/server/clio/adapters/docs.ts
1362
+ function within(root, target) {
1363
+ const rel = relative(root, target);
1364
+ return !isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`);
1365
+ }
1366
+ function contained(root, path) {
1367
+ if (!path || path.includes("\0") || path.includes("\\") || isAbsolute(path) || path.split("/").includes(".."))
1368
+ throw new AppProblem("unauthorized", "Documentation path is outside the allowed root.", 403);
1369
+ let target;
1370
+ try {
1371
+ target = realpathSync(resolve(root, path));
1372
+ } catch {
1373
+ throw new AppProblem("not_found", "Documentation file was not found.");
1374
+ }
1375
+ if (!within(root, target))
1376
+ throw new AppProblem("unauthorized", "Documentation path is outside the allowed root.", 403);
1377
+ return target;
1378
+ }
1379
+ function boundedRead(path, max) {
1380
+ const stat = statSync(path);
1381
+ if (!stat.isFile()) throw new AppProblem("not_found", "Documentation file was not found.");
1382
+ if (stat.size > max) throw new AppProblem("unavailable", "Documentation file exceeds the read limit.");
1383
+ return readFileSync(path);
1384
+ }
1385
+ function titleOf(path, markdown) {
1386
+ return /^#\s+(.+)$/m.exec(markdown)?.[1]?.replace(/[`*_]/g, "") ?? path.replace(/\.md$/i, "");
1387
+ }
1388
+ var DocsAdapter = class {
1389
+ constructor(packageRoot = resolvePackageRoot()) {
1390
+ this.packageRoot = packageRoot;
1391
+ }
1392
+ packageRoot;
1393
+ catalog;
1394
+ root;
1395
+ docsRoot() {
1396
+ this.root ??= contained(realpathSync(this.packageRoot), "docs");
1397
+ return this.root;
1398
+ }
1399
+ index() {
1400
+ if (this.catalog) return this.catalog;
1401
+ const root = this.docsRoot(), pages = /* @__PURE__ */ new Map(), visited = /* @__PURE__ */ new Set();
1402
+ let bytes = 0;
1403
+ const scan = (path) => {
1404
+ const directory = path ? contained(root, path) : root;
1405
+ if (visited.has(directory)) return;
1406
+ visited.add(directory);
1407
+ for (const entry of readdirSync(directory, { withFileTypes: true }).sort((a, b2) => a.name.localeCompare(b2.name))) {
1408
+ const name = path ? `${path}/${entry.name}` : entry.name;
1409
+ if (name === "html") continue;
1410
+ if (entry.isDirectory()) scan(name);
1411
+ else if (entry.isFile() && /\.md$/i.test(name)) {
1412
+ const markdown = boundedRead(contained(root, name), 1024 * 1024).toString("utf8");
1413
+ bytes += Buffer.byteLength(markdown);
1414
+ if (bytes > 16 * 1024 * 1024 || pages.size >= 1e4)
1415
+ throw new AppProblem("unavailable", "Documentation index exceeds its limit.");
1416
+ pages.set(name, {
1417
+ path: name,
1418
+ title: titleOf(name, markdown),
1419
+ markdown,
1420
+ anchors: new Set(documentHeadings(f.lexer(markdown)).values())
1421
+ });
1422
+ }
1423
+ }
1424
+ };
1425
+ scan("");
1426
+ const groups = [];
1427
+ let group;
1428
+ for (const token of f.lexer(pages.get("README.md")?.markdown ?? "")) {
1429
+ if (token.type === "heading" && token.depth === 2) {
1430
+ group = { title: token.text, pages: [] };
1431
+ groups.push(group);
1432
+ }
1433
+ if (token.type === "table" && group) {
1434
+ const current = group;
1435
+ f.walkTokens([token], (child) => {
1436
+ if (child.type !== "link") return;
1437
+ const page = pages.get(posix.normalize(child.href.split("#")[0] ?? ""));
1438
+ if (page && !current.pages.some((row) => row.path === page.path))
1439
+ current.pages.push({ path: page.path, title: page.title });
1440
+ });
1441
+ }
1442
+ }
1443
+ this.catalog = {
1444
+ pages,
1445
+ tree: {
1446
+ pages: [...pages.values()].map(({ path, title }) => ({ path, title })),
1447
+ groups: groups.filter((row) => row.pages.length)
1448
+ }
1449
+ };
1450
+ return this.catalog;
1451
+ }
1452
+ link(from, href) {
1453
+ const publicDocs = /^https:\/\/github\.com\/iowarp\/clio-coder\/(?:blob|tree)\/(?:main|v048)\/docs\/(.+)$/i.exec(
1454
+ href
1455
+ );
1456
+ if (publicDocs) href = `/${publicDocs[1]}`;
1457
+ if (/^(https?:|mailto:)/i.test(href)) return href;
1458
+ if (/^[a-z][a-z\d+.-]*:/i.test(href) || href.startsWith("//")) return null;
1459
+ let decoded;
1460
+ try {
1461
+ decoded = decodeURIComponent(href);
1462
+ } catch {
1463
+ return null;
1464
+ }
1465
+ if (/[\0\\]/.test(decoded)) return null;
1466
+ const [location = "", hash] = decoded.split("#", 2);
1467
+ const path = location.split("?")[0] || from;
1468
+ const normalized = posix.normalize(
1469
+ location ? path.startsWith("/") ? path.slice(1) : posix.join(dirname(from), path) : from
1470
+ );
1471
+ const pagePath = this.index().pages.has(normalized) ? normalized : `${normalized.replace(/\/$/, "")}/README.md`;
1472
+ const page = this.index().pages.get(pagePath);
1473
+ if (page) {
1474
+ if (hash && !page.anchors.has(hash)) return null;
1475
+ return `/docs/${pagePath.split("/").map(encodeURIComponent).join("/")}${hash ? `#${encodeURIComponent(hash)}` : ""}`;
1476
+ }
1477
+ const packagePath = posix.normalize(`docs/${normalized}`);
1478
+ try {
1479
+ contained(realpathSync(this.packageRoot), packagePath);
1480
+ } catch {
1481
+ return null;
1482
+ }
1483
+ return `https://github.com/iowarp/clio-coder/blob/main/${packagePath.split("/").map(encodeURIComponent).join("/")}${hash ? `#${encodeURIComponent(hash)}` : ""}`;
1484
+ }
1485
+ read(input) {
1486
+ if (input.kind === "tree") return this.index().tree;
1487
+ if (input.kind === "search") {
1488
+ const terms = input.q.toLowerCase().trim().split(/\s+/).filter(Boolean);
1489
+ if (!terms.length) return [];
1490
+ return [...this.index().pages.values()].map((page) => {
1491
+ const text = page.markdown.toLowerCase();
1492
+ const score = terms.reduce(
1493
+ (n, term) => n + (page.title.toLowerCase().includes(term) ? 100 : 0) + (page.path.toLowerCase().includes(term) ? 50 : 0) + Math.min(20, text.split(term).length - 1),
1494
+ 0
1495
+ );
1496
+ const at2 = Math.max(0, text.indexOf(terms[0] ?? ""));
1497
+ return {
1498
+ path: page.path,
1499
+ title: page.title,
1500
+ excerpt: page.markdown.slice(Math.max(0, at2 - 50), at2 + 180).replace(/\s+/g, " "),
1501
+ score
1502
+ };
1503
+ }).filter((row) => row.score > 0).sort((a, b2) => b2.score - a.score || a.path.localeCompare(b2.path)).slice(0, 30).map(({ score: _score, ...row }) => row);
1504
+ }
1505
+ if (!/\.md$/i.test(input.path)) throw new AppProblem("validation", "Only Markdown document paths are accepted.");
1506
+ const markdown = boundedRead(contained(this.docsRoot(), input.path), 1024 * 1024).toString("utf8");
1507
+ const links = /* @__PURE__ */ Object.create(null);
1508
+ const tokens = f.lexer(markdown);
1509
+ f.walkTokens(tokens, (token) => {
1510
+ if (token.type === "link") links[token.href] = this.link(input.path, token.href);
1511
+ });
1512
+ return {
1513
+ path: input.path,
1514
+ title: titleOf(input.path, markdown),
1515
+ markdown,
1516
+ headings: [...documentHeadings(tokens)].map(([token, id]) => ({
1517
+ id,
1518
+ title: token.text.replace(/<[^>]*>/g, "").replace(/[`*_~]/g, ""),
1519
+ depth: token.depth
1520
+ })),
1521
+ links,
1522
+ unavailableLinks: Object.entries(links).filter(([, destination]) => destination === null).map(([href]) => href)
1523
+ };
1524
+ }
1525
+ };
1526
+
1527
+ // apps/clio-coder-web/server/clio/adapters/sessions.ts
1528
+ init_esm_shims();
1529
+ import { existsSync, readdirSync as readdirSync2, realpathSync as realpathSync2 } from "node:fs";
1530
+ import { isAbsolute as isAbsolute2, join, relative as relative2, sep } from "node:path";
1531
+ function sessionHistory(cwd) {
1532
+ const state = clioStateDir(), directory = join(state, "sessions");
1533
+ if (!existsSync(directory)) return [];
1534
+ const root = realpathSync2(state);
1535
+ const inspect = (path, depth) => {
1536
+ const resolved = realpathSync2(path), part = relative2(root, resolved);
1537
+ if (part === ".." || part.startsWith(`..${sep}`) || isAbsolute2(part))
1538
+ throw new AppProblem("validation", "Session storage escapes its state directory.");
1539
+ if (depth > 0)
1540
+ for (const child of readdirSync2(path, { withFileTypes: true })) {
1541
+ const target = join(path, child.name);
1542
+ if (child.isDirectory()) inspect(target, depth - 1);
1543
+ else {
1544
+ const file = realpathSync2(target), diff = relative2(root, file);
1545
+ if (diff === ".." || diff.startsWith(`..${sep}`) || isAbsolute2(diff))
1546
+ throw new AppProblem("validation", "Session storage escapes its state directory.");
1547
+ }
1548
+ }
1549
+ };
1550
+ inspect(directory, 3);
1551
+ return listSessionsForCwd(cwd);
1552
+ }
1553
+
1554
+ // apps/clio-coder-web/server/clio/adapters/traces.ts
1555
+ init_esm_shims();
1556
+ import { readFileSync as readFileSync2, realpathSync as realpathSync3, statSync as statSync2 } from "node:fs";
1557
+ import { isAbsolute as isAbsolute3, join as join2, relative as relative3 } from "node:path";
1558
+ var Cursor = typebox_exports.Object({ startedAt: typebox_exports.String({ maxLength: 64 }), runId: Id }, { additionalProperties: false });
1559
+ function cursorOf(encoded) {
1560
+ if (encoded === void 0) return null;
1561
+ try {
1562
+ const decoded = JSON.parse(Buffer.from(encoded, "base64url").toString("utf8"));
1563
+ if (!value_exports.Check(Cursor, decoded) || !Number.isFinite(Date.parse(decoded.startedAt))) throw new Error("cursor");
1564
+ return decoded;
1565
+ } catch {
1566
+ throw new AppProblem("validation", "Invalid trace pagination cursor.");
1567
+ }
1568
+ }
1569
+ function inside(root, path) {
1570
+ const part = relative3(root, path);
1571
+ return part !== ".." && !part.startsWith("../") && !isAbsolute3(part);
1572
+ }
1573
+ function contained2(state, directory, filename) {
1574
+ const root = realpathSync3(state), base = realpathSync3(join2(state, directory)), path = realpathSync3(join2(base, filename));
1575
+ if (!inside(root, base) || !inside(base, path))
1576
+ throw new AppProblem("validation", "Trace path escapes its state directory.");
1577
+ return path;
1578
+ }
1579
+ var TraceAdapter = class {
1580
+ reader;
1581
+ identity = "";
1582
+ close() {
1583
+ this.reader?.close();
1584
+ this.reader = void 0;
1585
+ }
1586
+ open() {
1587
+ const state = clioStateDir();
1588
+ const path = contained2(state, ".", relative3(state, traceDatabasePath(state)));
1589
+ const info = statSync2(path), identity = `${info.dev}:${info.ino}`;
1590
+ if (this.reader && this.identity !== identity) this.close();
1591
+ if (!this.reader) {
1592
+ this.reader = new TraceReader(path);
1593
+ this.identity = identity;
1594
+ }
1595
+ const version = this.reader.db.prepare("SELECT value FROM meta WHERE key='schema_version'").get();
1596
+ if (Number(version?.value) !== TRACE_SCHEMA_VERSION) {
1597
+ this.close();
1598
+ throw new Error("Unsupported trace schema.");
1599
+ }
1600
+ return this.reader;
1601
+ }
1602
+ read(input) {
1603
+ const cursor = input.kind === "runs" ? cursorOf(input.query.cursor) : null;
1604
+ if ("runId" in input && (!value_exports.Check(Id, input.runId) || input.runId.includes("..")))
1605
+ throw new AppProblem("validation", "Invalid trace run identifier.");
1606
+ if (input.kind === "receipt") return this.receipt(input.runId, input.full ?? false);
1607
+ try {
1608
+ const reader = this.open();
1609
+ if (input.kind === "status")
1610
+ return { available: true, schemaVersion: TRACE_SCHEMA_VERSION, retentionPolicy: resolveTraceRetentionPolicy() };
1611
+ if (input.kind === "runs") {
1612
+ const { source, status, q: q2, limit } = input.query;
1613
+ const page = reader.runsPage({
1614
+ ...cursor ? { before: cursor } : {},
1615
+ ...limit !== void 0 ? { limit } : {},
1616
+ filter: { ...source ? { source } : {}, ...status ? { status } : {}, ...q2 ? { q: q2 } : {} }
1617
+ });
1618
+ return {
1619
+ runs: page.runs,
1620
+ nextCursor: page.nextBefore ? Buffer.from(JSON.stringify(page.nextBefore)).toString("base64url") : null
1621
+ };
1622
+ }
1623
+ const run = reader.run(input.runId);
1624
+ if (!run) throw new AppProblem("not_found", "Trace run was not found.");
1625
+ switch (input.kind) {
1626
+ case "run":
1627
+ return run;
1628
+ case "phases":
1629
+ return reader.phases(input.runId);
1630
+ case "gates":
1631
+ return reader.gateResults(input.runId);
1632
+ case "envelopes":
1633
+ return reader.envelopes(input.runId);
1634
+ case "processes":
1635
+ return reader.processes(input.runId);
1636
+ case "events":
1637
+ case "live": {
1638
+ const events = reader.events(input.runId, input.after, input.limit);
1639
+ return {
1640
+ ...input.kind === "live" ? { run } : {},
1641
+ events,
1642
+ cursor: events.at(-1)?.rowid ?? input.after,
1643
+ hasMore: events.length === input.limit
1644
+ };
1645
+ }
1646
+ }
1647
+ } catch (error) {
1648
+ this.close();
1649
+ if (error instanceof AppProblem) throw error;
1650
+ if (input.kind === "status")
1651
+ return { available: false, schemaVersion: null, retentionPolicy: resolveTraceRetentionPolicy() };
1652
+ throw new AppProblem("unavailable", "Trace database is unavailable or has an unsupported schema or journal mode.");
1653
+ }
1654
+ }
1655
+ receipt(runId, full) {
1656
+ const state = clioStateDir();
1657
+ let receipt = null;
1658
+ let evidence = null;
1659
+ try {
1660
+ const path = contained2(state, "receipts", `${runId}.json`);
1661
+ const data = JSON.parse(readFileSync2(path, "utf8"));
1662
+ if (data && typeof data === "object" && !Array.isArray(data)) receipt = data;
1663
+ } catch (error) {
1664
+ if (error instanceof AppProblem) throw error;
1665
+ }
1666
+ try {
1667
+ contained2(state, ".", "evidence-index.json");
1668
+ evidence = readEvidenceIndex(state).find((row) => row.runId === runId) ?? null;
1669
+ } catch (error) {
1670
+ if (error instanceof AppProblem) throw error;
1671
+ }
1672
+ if (receipt && !full)
1673
+ for (const key of ["output", "upstreamResponses", "routeDecision", "briefing", "steering"]) delete receipt[key];
1674
+ return { receipt, evidence };
1675
+ }
1676
+ };
1677
+
1678
+ // apps/clio-coder-web/server/worker/reads-main.ts
1679
+ var settings = workerData;
1680
+ restrictNetwork();
1681
+ var fixture = false ? await null : void 0;
1682
+ var adapter = toolchainAdapter(fixture?.fixtureOptions(settings));
1683
+ var traces = new TraceAdapter();
1684
+ var docs = new DocsAdapter(settings.fixture ? settings.fixtureDocsPackageRoot : void 0);
1685
+ serveWorker(async (call) => {
1686
+ if (call.method === "runtime.info" && process.env.NODE_ENV === "test") return runtimeInfo(import.meta.url);
1687
+ if (call.method === "system.read" || call.method === "interop.read") {
1688
+ const { inspectSystem, inspectInterop } = await import("../system-3TDQRMZZ.js");
1689
+ return call.method === "system.read" ? inspectSystem() : inspectInterop(call.params.cwd, settings.fixture);
1690
+ }
1691
+ if (call.method === "library.read") {
1692
+ const { readLibrary } = await import("../library-3J5IO2OJ.js");
1693
+ return readLibrary(call.params);
1694
+ }
1695
+ if (call.method === "evals.read") {
1696
+ const { readEvals } = await import("../evals-L73EBHSU.js");
1697
+ return readEvals(call.params);
1698
+ }
1699
+ if (call.method === "evidence.read") {
1700
+ const { readEvidence } = await import("../evidence-Y55WKYHH.js");
1701
+ return readEvidence(call.params);
1702
+ }
1703
+ if (call.method === "fleet.read") {
1704
+ const { readFleet } = await import("../fleet-M4H2QBWT.js");
1705
+ return readFleet(call.params);
1706
+ }
1707
+ if (call.method === "settings.read") {
1708
+ const { inspectSettings } = await import("../settings-3VMBMWID.js");
1709
+ return inspectSettings(call.params.cwd);
1710
+ }
1711
+ if (call.method === "config.graph") {
1712
+ if (settings.fixture && settings.fixtureGraphDelayMs)
1713
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, settings.fixtureGraphDelayMs);
1714
+ const { inspectConfigGraph } = await import("../config-graph-GKAOBAS5.js");
1715
+ return inspectConfigGraph(call.params.cwd);
1716
+ }
1717
+ if (call.method === "docs.read") return docs.read(call.params);
1718
+ if (call.method === "sessions.list") return sessionHistory(call.params.cwd);
1719
+ if (call.method === "traces.read") return traces.read(call.params);
1720
+ if (call.method !== "tools.list") throw new AppProblem("unsupported", "Method is not available in the reads worker.");
1721
+ if (settings.fixture && settings.readDelayMs)
1722
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, settings.readDelayMs);
1723
+ if (settings.fixture && settings.crashRead) process.exit(7);
1724
+ return adapter.list();
1725
+ });
1726
+ //# sourceMappingURL=reads-worker.js.map