@plebeiantech/lat.md 0.12.3-fork.8 → 0.13.4-fork.1

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 (330) hide show
  1. package/README.md +27 -3
  2. package/dist/src/cli/agent-invocation.d.ts +6 -0
  3. package/dist/src/cli/agent-invocation.js +23 -0
  4. package/dist/src/cli/checklist-menu.d.ts +2 -1
  5. package/dist/src/cli/checklist-menu.js +3 -2
  6. package/dist/src/cli/fork-instructions.d.ts +1 -0
  7. package/dist/src/cli/fork-instructions.js +8 -32
  8. package/dist/src/cli/fork-scaffold.js +2 -2
  9. package/dist/src/cli/graph.d.ts +1 -1
  10. package/dist/src/cli/hook.d.ts +26 -0
  11. package/dist/src/cli/hook.js +115 -64
  12. package/dist/src/cli/index.js +147 -70
  13. package/dist/src/cli/init-preferences.d.ts +4 -0
  14. package/dist/src/cli/init-preferences.js +36 -0
  15. package/dist/src/cli/init.d.ts +2 -1
  16. package/dist/src/cli/init.js +100 -60
  17. package/dist/src/cli/reindex.d.ts +1 -1
  18. package/dist/src/cli/reindex.js +7 -10
  19. package/dist/src/cli/search.d.ts +14 -4
  20. package/dist/src/cli/search.js +115 -101
  21. package/dist/src/cli/ui-build-server.d.ts +12 -0
  22. package/dist/src/cli/ui-build-server.js +26 -0
  23. package/dist/src/cli/ui-build.d.ts +1 -1
  24. package/dist/src/cli/ui-build.js +1 -1
  25. package/dist/src/cli/ui.d.ts +1 -1
  26. package/dist/src/cli/ui.js +1 -1
  27. package/dist/src/fork/antigravity-hook.d.ts +47 -0
  28. package/dist/src/fork/antigravity-hook.js +424 -0
  29. package/dist/src/fork/antigravity-init.d.ts +17 -0
  30. package/dist/src/fork/antigravity-init.js +124 -0
  31. package/dist/src/fork/upstream-drift.js +1 -1
  32. package/dist/src/fork/upstream-guard.d.ts +1 -1
  33. package/dist/src/fork/upstream-guard.js +8 -7
  34. package/dist/src/graph-export.js +7 -7
  35. package/dist/src/knowledge/index.js +2 -2
  36. package/dist/src/mcp/server.js +34 -18
  37. package/dist/src/search/cache.d.ts +3 -0
  38. package/dist/src/search/cache.js +104 -0
  39. package/dist/src/search/chunks.d.ts +23 -0
  40. package/dist/src/search/chunks.js +200 -0
  41. package/dist/src/search/db.d.ts +28 -16
  42. package/dist/src/search/db.js +100 -40
  43. package/dist/src/search/embedder.d.ts +2 -1
  44. package/dist/src/search/embedder.js +7 -6
  45. package/dist/src/search/index.d.ts +6 -2
  46. package/dist/src/search/index.js +176 -53
  47. package/dist/src/search/lexical.d.ts +6 -0
  48. package/dist/src/search/lexical.js +36 -0
  49. package/dist/src/search/lock.d.ts +5 -0
  50. package/dist/src/search/lock.js +45 -0
  51. package/dist/src/search/query.d.ts +26 -0
  52. package/dist/src/search/query.js +103 -0
  53. package/dist/src/search/search.d.ts +16 -7
  54. package/dist/src/search/search.js +165 -21
  55. package/dist/src/search/types.d.ts +15 -0
  56. package/dist/src/view/client/assets/GraphView-D_xnk0bP.js +456 -0
  57. package/dist/src/view/client/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  58. package/dist/src/view/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  59. package/dist/src/view/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  60. package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  61. package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  62. package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  63. package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  64. package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  65. package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  66. package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  67. package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  68. package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  69. package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  70. package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  71. package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  72. package/dist/src/view/client/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  73. package/dist/src/view/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  74. package/dist/src/view/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  75. package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  76. package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  77. package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  78. package/dist/src/view/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  79. package/dist/src/view/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  80. package/dist/src/view/client/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  81. package/dist/src/view/client/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  82. package/dist/src/view/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  83. package/dist/src/view/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  84. package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  85. package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  86. package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  87. package/dist/src/view/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  88. package/dist/src/view/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  89. package/dist/src/view/client/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  90. package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  91. package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  92. package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  93. package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  94. package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  95. package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  96. package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  97. package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  98. package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  99. package/dist/src/view/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  100. package/dist/src/view/client/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  101. package/dist/src/view/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  102. package/dist/src/view/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  103. package/dist/src/view/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  104. package/dist/src/view/client/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  105. package/dist/src/view/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  106. package/dist/src/view/client/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  107. package/dist/src/view/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  108. package/dist/src/view/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  109. package/dist/src/view/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  110. package/dist/src/view/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  111. package/dist/src/view/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  112. package/dist/src/view/client/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  113. package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  114. package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  115. package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  116. package/dist/src/view/client/assets/MarkdownEditor-bjqt_FoF.js +28 -0
  117. package/dist/src/view/client/assets/OrbitControls-DwcpQNja.js +1 -0
  118. package/dist/src/view/client/assets/STLLoader-CLWTKt5i.js +1 -0
  119. package/dist/src/view/client/assets/_commonjsHelpers-CqkleIqs.js +1 -0
  120. package/dist/src/view/client/assets/abnfDiagram-VCTEODGH-kWGvtRnL.js +1 -0
  121. package/dist/src/view/client/assets/arc-BPAFd7cP.js +1 -0
  122. package/dist/src/view/client/assets/architectureDiagram-5GKGNRK7-CsY39oIR.js +36 -0
  123. package/dist/src/view/client/assets/blockDiagram-I7D4REHJ-DHGBG7BJ.js +129 -0
  124. package/dist/src/view/client/assets/c4Diagram-7LVT6UL2-vywK4eb7.js +38 -0
  125. package/dist/src/view/client/assets/channel-CX71L_qV.js +1 -0
  126. package/dist/src/view/client/assets/chunk-2Q5K7J3B-Do3Hz_ci.js +1 -0
  127. package/dist/src/view/client/assets/chunk-5VM5RSS4-B5R1lSeY.js +15 -0
  128. package/dist/src/view/client/assets/chunk-F27PBJKO-Dm55FM_W.js +1 -0
  129. package/dist/src/view/client/assets/chunk-IMKFNOWR-ChptrvvM.js +231 -0
  130. package/dist/src/view/client/assets/chunk-JWPE2WC7-BRQBjrKS.js +1 -0
  131. package/dist/src/view/client/assets/chunk-POPQ4Y6H-CainVZIL.js +1 -0
  132. package/dist/src/view/client/assets/chunk-SVP7TREG-DsKsNGmM.js +88 -0
  133. package/dist/src/view/client/assets/chunk-TICWLB2K-BctkMcJc.js +206 -0
  134. package/dist/src/view/client/assets/chunk-XXDRQBXY-BN7SgOUT.js +1 -0
  135. package/dist/src/view/client/assets/classDiagram-ZZMXUADV-B1VyU6zO.js +1 -0
  136. package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-B1VyU6zO.js +1 -0
  137. package/dist/src/view/client/assets/cose-bilkent-JH36ORCC-BszzwrMe.js +1 -0
  138. package/dist/src/view/client/assets/cynefin-OW5HDTMX-CdRyAkPs.js +166 -0
  139. package/dist/src/view/client/assets/cynefinDiagram-5FMLGOSQ-BLvKPZ1u.js +62 -0
  140. package/dist/src/view/client/assets/cytoscape.esm-DzSz-X2X.js +321 -0
  141. package/dist/src/view/client/assets/dagre-GXQ25YYZ-V68w_l65.js +4 -0
  142. package/dist/src/view/client/assets/defaultLocale-DX6XiGOO.js +1 -0
  143. package/dist/src/view/client/assets/diagram-S7CK7UJ4-C2i4eEMg.js +30 -0
  144. package/dist/src/view/client/assets/diagram-UQ7AKVKN-BiwWh5jC.js +41 -0
  145. package/dist/src/view/client/assets/diagram-VSXAHHWV-hkKR_vyS.js +3 -0
  146. package/dist/src/view/client/assets/diagram-VX7I27RA-DzRCSMAc.js +24 -0
  147. package/dist/src/view/client/assets/diagram-Z3DM3KII-fhSFPxyK.js +24 -0
  148. package/dist/src/view/client/assets/ebnfDiagram-PWID7BFC-CCEUDKSA.js +1 -0
  149. package/dist/src/view/client/assets/erDiagram-RLTQ6QDP-FJ2IMyTi.js +99 -0
  150. package/dist/src/view/client/assets/flowDiagram-HODETNUW-BvasdLeK.js +168 -0
  151. package/dist/src/view/client/assets/ganttDiagram-EL5Y4UJY-CiwkBZvY.js +292 -0
  152. package/dist/src/view/client/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  153. package/dist/src/view/client/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  154. package/dist/src/view/client/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  155. package/dist/src/view/client/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  156. package/dist/src/view/client/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
  157. package/dist/src/view/client/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
  158. package/dist/src/view/client/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
  159. package/dist/src/view/client/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
  160. package/dist/src/view/client/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
  161. package/dist/src/view/client/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
  162. package/dist/src/view/client/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  163. package/dist/src/view/client/assets/gitGraphDiagram-WWUBYQGX-DYlP2_js.js +106 -0
  164. package/dist/src/view/client/assets/index-BnENo9bV.js +1 -0
  165. package/dist/src/view/client/assets/index-CQ7EOox7.css +1 -0
  166. package/dist/src/view/client/assets/index-CynNDkxt.js +13 -0
  167. package/dist/src/view/client/assets/infoDiagram-27XIBGKW-DRPB2c48.js +2 -0
  168. package/dist/src/view/client/assets/init-Gi6I4Gst.js +1 -0
  169. package/dist/src/view/client/assets/ishikawaDiagram-5VMMS53U-8VV429Cv.js +70 -0
  170. package/dist/src/view/client/assets/journeyDiagram-3NMN7TZE-Dzmwnf83.js +139 -0
  171. package/dist/src/view/client/assets/kanban-definition-UXKFOSKX-pYyZZ1i-.js +89 -0
  172. package/dist/src/view/client/assets/katex-HP8lGamR.js +257 -0
  173. package/dist/src/view/client/assets/layout-GF9k6yGo.js +1 -0
  174. package/dist/src/view/client/assets/linear-Yt2sSOYV.js +1 -0
  175. package/dist/src/view/client/assets/logo-RR_KBOAT.svg +149 -0
  176. package/dist/src/view/client/assets/maplibre-gl-CDX6Zuow.js +800 -0
  177. package/dist/src/view/client/assets/mermaid.core-ChWYCHN0.js +310 -0
  178. package/dist/src/view/client/assets/mindmap-definition-YA3MSWOX-Cc4fQvf1.js +96 -0
  179. package/dist/src/view/client/assets/ordinal-Cboi1Yqb.js +1 -0
  180. package/dist/src/view/client/assets/pegDiagram-XKGWAZYB-C0SsB8bZ.js +1 -0
  181. package/dist/src/view/client/assets/pieDiagram-E7YTZNPT-DIJpqERZ.js +39 -0
  182. package/dist/src/view/client/assets/quadrantDiagram-AXDQQJYC--d-gl6j-.js +7 -0
  183. package/dist/src/view/client/assets/railroadDiagram-O6MQD6OU-BQxwTt7z.js +1 -0
  184. package/dist/src/view/client/assets/requirementDiagram-BXWQKSXE-B_oTeD2A.js +84 -0
  185. package/dist/src/view/client/assets/sankeyDiagram-P5KCCOFB-DLukmE8X.js +40 -0
  186. package/dist/src/view/client/assets/sequenceDiagram-WJ2MYXX4-BNjVB2sc.js +162 -0
  187. package/dist/src/view/client/assets/sizeCapture-INFHLROL-BZecQTOw.js +1 -0
  188. package/dist/src/view/client/assets/stateDiagram-D77RDMKH-Bu1urvXC.js +1 -0
  189. package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-5pc_697G.js +1 -0
  190. package/dist/src/view/client/assets/swimlanes-42K2YHIH-bLAlcepB.js +1 -0
  191. package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-BbOpZjpp.js +8 -0
  192. package/dist/src/view/client/assets/three.module-PDSP0dbZ.js +4108 -0
  193. package/dist/src/view/client/assets/timeline-definition-24CTP7MA-tbwCNvcA.js +120 -0
  194. package/dist/src/view/client/assets/vennDiagram-4TSXK5OY-D8U8Fk0N.js +34 -0
  195. package/dist/src/view/client/assets/wardleyDiagram-VM6X3IG4-LHBVIeNb.js +78 -0
  196. package/dist/src/view/client/assets/xychartDiagram-S5SC5T6Z-CN4tfaFV.js +7 -0
  197. package/dist/src/view/client/index.html +2 -2
  198. package/dist/src/view/client-shell.d.ts +2 -0
  199. package/dist/src/view/client-shell.js +5 -0
  200. package/dist/src/view/diagnostics.d.ts +3 -2
  201. package/dist/src/view/diagnostics.js +49 -58
  202. package/dist/src/view/document-edit.d.ts +8 -0
  203. package/dist/src/view/document-edit.js +25 -0
  204. package/dist/src/view/document-route.d.ts +14 -0
  205. package/dist/src/view/document-route.js +137 -0
  206. package/dist/src/view/document-tree.d.ts +18 -0
  207. package/dist/src/view/document-tree.js +139 -0
  208. package/dist/src/view/external-document-tree.d.ts +3 -0
  209. package/dist/src/view/external-document-tree.js +674 -0
  210. package/dist/src/view/git-diff.js +202 -2
  211. package/dist/src/view/git.js +1 -1
  212. package/dist/src/view/graph.d.ts +4 -3
  213. package/dist/src/view/graph.js +100 -9
  214. package/dist/src/view/highlight.d.ts +10 -2
  215. package/dist/src/view/highlight.js +50648 -3166
  216. package/dist/src/view/markdown.d.ts +3 -2
  217. package/dist/src/view/markdown.js +256 -54
  218. package/dist/src/view/preindexed-search.d.ts +15 -0
  219. package/dist/src/view/preindexed-search.js +25 -0
  220. package/dist/src/view/protocol.d.ts +53 -7
  221. package/dist/src/view/publication.d.ts +2 -0
  222. package/dist/src/view/publication.js +78 -0
  223. package/dist/src/view/references.d.ts +11 -26
  224. package/dist/src/view/references.js +121 -112
  225. package/dist/src/view/repository.d.ts +14 -4
  226. package/dist/src/view/repository.js +260 -19
  227. package/dist/src/view/request-security.d.ts +5 -0
  228. package/dist/src/view/request-security.js +46 -0
  229. package/dist/src/view/search-result.d.ts +4 -0
  230. package/dist/src/view/search-result.js +25 -0
  231. package/dist/src/view/search.d.ts +7 -2
  232. package/dist/src/view/search.js +23 -34
  233. package/dist/src/view/server-build.d.ts +21 -0
  234. package/dist/src/view/server-build.js +145 -0
  235. package/dist/src/view/server-deployment.d.ts +31 -0
  236. package/dist/src/view/server-deployment.js +123 -0
  237. package/dist/src/view/server-index-worker.d.ts +6 -0
  238. package/dist/src/view/server-index-worker.js +14 -0
  239. package/dist/src/view/server.d.ts +11 -2
  240. package/dist/src/view/server.js +245 -73
  241. package/dist/src/view/source-target.d.ts +2 -0
  242. package/dist/src/view/source-target.js +49 -8
  243. package/dist/src/view/static-build.d.ts +18 -2
  244. package/dist/src/view/static-build.js +449 -110
  245. package/dist/src/view/static-protocol.d.ts +26 -2
  246. package/dist/src/view/static-protocol.js +5 -0
  247. package/dist/src/view/store.d.ts +20 -3
  248. package/dist/src/view/store.js +304 -48
  249. package/dist/src/view/table-of-contents.d.ts +2 -2
  250. package/dist/src/view/table-of-contents.js +2 -22
  251. package/dist/src/view/vercel-build.d.ts +24 -0
  252. package/dist/src/view/vercel-build.js +152 -0
  253. package/dist/src/view/vercel-server-build.d.ts +10 -0
  254. package/dist/src/view/vercel-server-build.js +61 -0
  255. package/dist/vendor/lat.md-server/cli.d.ts +2 -0
  256. package/dist/vendor/lat.md-server/cli.js +12 -0
  257. package/dist/vendor/lat.md-server/index.d.ts +38 -0
  258. package/dist/vendor/lat.md-server/index.js +128 -0
  259. package/package.json +68 -22
  260. package/plugins/lat-md/README.md +61 -0
  261. package/plugins/lat-md/hooks.json +38 -0
  262. package/plugins/lat-md/plugin.json +9 -0
  263. package/plugins/lat-md/rules/AGENTS.md +344 -0
  264. package/plugins/lat-md/skills/lat-md/SKILL.md +210 -0
  265. package/plugins/lat-md/skills/lat-md-conventions/SKILL.md +226 -0
  266. package/templates/AGENTS.md +26 -7
  267. package/templates/cursor-rules.md +23 -7
  268. package/templates/fork/conventions.md +133 -11
  269. package/templates/opencode-plugin.ts +9 -9
  270. package/templates/pi-extension.ts +11 -11
  271. package/templates/skill/SKILL.md +35 -3
  272. package/dist/src/cli/check-coverage.d.ts +0 -2
  273. package/dist/src/cli/check-coverage.js +0 -71
  274. package/dist/src/cli/check-frontmatter.d.ts +0 -12
  275. package/dist/src/cli/check-frontmatter.js +0 -44
  276. package/dist/src/cli/check-mode.d.ts +0 -21
  277. package/dist/src/cli/check-mode.js +0 -364
  278. package/dist/src/cli/check-status.d.ts +0 -74
  279. package/dist/src/cli/check-status.js +0 -217
  280. package/dist/src/cli/check.d.ts +0 -45
  281. package/dist/src/cli/check.js +0 -781
  282. package/dist/src/cli/context.d.ts +0 -11
  283. package/dist/src/cli/context.js +0 -58
  284. package/dist/src/cli/expand.d.ts +0 -8
  285. package/dist/src/cli/expand.js +0 -94
  286. package/dist/src/cli/gen-index.d.ts +0 -45
  287. package/dist/src/cli/gen-index.js +0 -235
  288. package/dist/src/cli/link-scheme.d.ts +0 -54
  289. package/dist/src/cli/link-scheme.js +0 -101
  290. package/dist/src/cli/locate.d.ts +0 -2
  291. package/dist/src/cli/locate.js +0 -17
  292. package/dist/src/cli/refs.d.ts +0 -22
  293. package/dist/src/cli/refs.js +0 -229
  294. package/dist/src/cli/section.d.ts +0 -43
  295. package/dist/src/cli/section.js +0 -252
  296. package/dist/src/cli/select-menu.d.ts +0 -13
  297. package/dist/src/cli/select-menu.js +0 -100
  298. package/dist/src/code-refs.d.ts +0 -17
  299. package/dist/src/code-refs.js +0 -298
  300. package/dist/src/config.d.ts +0 -29
  301. package/dist/src/config.js +0 -83
  302. package/dist/src/context.d.ts +0 -23
  303. package/dist/src/context.js +0 -11
  304. package/dist/src/extensions/wiki-link/from-markdown.d.ts +0 -5
  305. package/dist/src/extensions/wiki-link/from-markdown.js +0 -34
  306. package/dist/src/extensions/wiki-link/index.d.ts +0 -4
  307. package/dist/src/extensions/wiki-link/index.js +0 -3
  308. package/dist/src/extensions/wiki-link/syntax.d.ts +0 -14
  309. package/dist/src/extensions/wiki-link/syntax.js +0 -121
  310. package/dist/src/extensions/wiki-link/to-markdown.d.ts +0 -5
  311. package/dist/src/extensions/wiki-link/to-markdown.js +0 -28
  312. package/dist/src/extensions/wiki-link/types.d.ts +0 -34
  313. package/dist/src/format.d.ts +0 -8
  314. package/dist/src/format.js +0 -43
  315. package/dist/src/init-version.d.ts +0 -10
  316. package/dist/src/init-version.js +0 -49
  317. package/dist/src/lattice.d.ts +0 -109
  318. package/dist/src/lattice.js +0 -817
  319. package/dist/src/parser.d.ts +0 -3
  320. package/dist/src/parser.js +0 -18
  321. package/dist/src/source-parser.d.ts +0 -27
  322. package/dist/src/source-parser.js +0 -916
  323. package/dist/src/untrusted.d.ts +0 -18
  324. package/dist/src/untrusted.js +0 -93
  325. package/dist/src/view/client/assets/index-VZwPPiFE.js +0 -334
  326. package/dist/src/view/client/assets/index-W8ktvNj9.css +0 -1
  327. package/dist/src/view/client/assets/logo-CNF8zs47.svg +0 -182
  328. package/dist/src/walk.d.ts +0 -18
  329. package/dist/src/walk.js +0 -27
  330. /package/dist/src/{extensions/wiki-link → search}/types.js +0 -0
@@ -1,298 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { execFile } from 'node:child_process';
3
- import { join, posix, relative } from 'node:path';
4
- import { toPosix, walkEntries } from './walk.js';
5
- /** Glob patterns used to exclude directories/files from code-ref scanning.
6
- * Shared between rg args and the TS fallback's walkFiles filter. */
7
- const EXCLUDE_DIRS = ['lat.md', '.claude'];
8
- const EXCLUDE_GLOBS = ['*.md'];
9
- /** Walk project files for code-ref scanning. Uses walkEntries for .gitignore
10
- * support, then additionally skips .md files, lat.md/, .claude/, and sub-projects. */
11
- export async function walkFiles(dir) {
12
- const entries = (await walkEntries(dir)).map(toPosix);
13
- const generatedOutputs = new Set(entries
14
- .filter((entry) => entry.endsWith('/.lat-ui-build'))
15
- .map((entry) => `${posix.dirname(entry)}/`));
16
- // Collect directories that contain their own lat.md/ (sub-projects)
17
- const subProjects = new Set();
18
- for (const e of entries) {
19
- const i = e.indexOf('/lat.md/');
20
- if (i !== -1)
21
- subProjects.add(e.slice(0, i + 1));
22
- }
23
- return entries
24
- .filter((e) => !e.endsWith('.md') &&
25
- !e.startsWith('lat.md/') &&
26
- !e.startsWith('.claude/') &&
27
- ![...generatedOutputs].some((prefix) => e.startsWith(prefix)) &&
28
- ![...subProjects].some((prefix) => e.startsWith(prefix)))
29
- .map((e) => join(dir, e));
30
- }
31
- /** Build a RegExp from a verbose template — whitespace is insignificant. */
32
- function re(flags) {
33
- return (strings) => new RegExp(strings.raw[0].replace(/\s+/g, ''), flags);
34
- }
35
- // Line comment (// or #), then @lat: marker, then [[target]]
36
- export const LAT_REF_RE = re('gv') `
37
- (?: // | # )
38
- \s* @lat: \s*
39
- \[\[
40
- ( [^\]]+ )
41
- \]\]
42
- `;
43
- /** Explicit opt-out: a standalone `lat:ignore` token anywhere on the line
44
- * suppresses any @lat: match on that line. This gives an author documenting
45
- * the syntax one obvious escape hatch when a match isn't inside a
46
- * quoted/backticked literal (the common case handled by
47
- * `isInsideQuotedSpan`). Word-boundary lookarounds (rather than `\b`, which
48
- * treats `:` as a boundary on both sides already and wouldn't help) keep
49
- * incidental substrings — `lat:ignore-config`, `mylat:ignore` — from
50
- * suppressing a real ref on the same line, while still matching the token
51
- * at the very start of a line or glued directly to a comment marker
52
- * (`//lat:ignore`), since `/` isn't a word character either. */
53
- const LAT_IGNORE_RE = /(?<![\w])lat:ignore(?![-\w])/;
54
- /** Quote characters treated as delimiting a literal span: plain strings
55
- * ('...' or "...") and backtick spans, which double as inline-code markers
56
- * when a comment is documenting the @lat: syntax itself (e.g. `` `@lat:
57
- * [[section-id]]` ``). A marker whose match falls inside such a span is an
58
- * example, not a real reference, so it is not returned as a ref. */
59
- const QUOTE_CHARS = ['"', '`', "'"];
60
- /**
61
- * Returns true if `index` (an offset into `line`) falls inside a
62
- * quote-delimited span on that line. For each quote character, occurrences
63
- * are paired up in order (open, close, open, close, ...); if a quote
64
- * character appears an odd number of times on the line, it's ambiguous
65
- * (e.g. an apostrophe in prose) and is ignored entirely for that line rather
66
- * than risk hiding a real reference.
67
- */
68
- function isInsideQuotedSpan(line, index) {
69
- for (const q of QUOTE_CHARS) {
70
- const positions = [];
71
- for (let i = 0; i < line.length; i++) {
72
- if (line[i] === q && line[i - 1] !== '\\')
73
- positions.push(i);
74
- }
75
- if (positions.length < 2 || positions.length % 2 !== 0)
76
- continue;
77
- for (let i = 0; i < positions.length; i += 2) {
78
- if (index > positions[i] && index < positions[i + 1])
79
- return true;
80
- }
81
- }
82
- return false;
83
- }
84
- /** Filter regex matches on a single line, dropping ones that are inside a
85
- * quoted/backticked literal or on a line carrying an explicit `lat:ignore`
86
- * opt-out — these document the @lat: syntax rather than using it. */
87
- function extractRefsFromLine(line) {
88
- if (LAT_IGNORE_RE.test(line))
89
- return [];
90
- const targets = [];
91
- LAT_REF_RE.lastIndex = 0;
92
- let match;
93
- while ((match = LAT_REF_RE.exec(line)) !== null) {
94
- if (!isInsideQuotedSpan(line, match.index)) {
95
- targets.push(match[1]);
96
- }
97
- }
98
- return targets;
99
- }
100
- /**
101
- * Run an external command and return stdout, or null if the command is not found
102
- * or fails.
103
- */
104
- function tryExec(cmd, args, cwd) {
105
- return new Promise((resolve) => {
106
- execFile(cmd, args, { cwd, maxBuffer: 50 * 1024 * 1024 }, (err, out) => {
107
- if (err) {
108
- // Exit code 1 with no stderr typically means "no matches" for grep/rg
109
- const exitCode = err.code;
110
- if (exitCode === 'ENOENT') {
111
- resolve(null); // command not found
112
- return;
113
- }
114
- // rg/grep exit 1 = no matches (not an error)
115
- if ('status' in err &&
116
- err.status === 1 &&
117
- out === '') {
118
- resolve('');
119
- return;
120
- }
121
- resolve(null);
122
- return;
123
- }
124
- resolve(out);
125
- });
126
- });
127
- }
128
- /**
129
- * Detect sub-projects (directories containing their own lat.md/) using
130
- * rg --files. Finds files inside nested lat.md/ dirs and extracts the parent
131
- * directory paths. Returns paths relative to projectRoot.
132
- */
133
- async function findSubProjects(projectRoot) {
134
- // List files inside any lat.md/ dir, then extract unique parent paths.
135
- // The root lat.md/ is excluded by EXCLUDE_DIRS in the caller, so we only
136
- // need to find nested ones here — search for files under */lat.md/.
137
- const out = await tryExec('rg', ['--files', '--glob', '**/lat.md/**', '.'], projectRoot);
138
- if (!out)
139
- return [];
140
- const subProjects = new Set();
141
- for (const rawLine of out.split('\n')) {
142
- if (!rawLine)
143
- continue;
144
- // rg emits native separators on Windows; normalize before matching '/lat.md/'.
145
- const line = toPosix(rawLine);
146
- const clean = line.startsWith('./') ? line.slice(2) : line;
147
- // "tests/cases/foo/lat.md/specs.md" → "tests/cases/foo"
148
- // Skip root lat.md/ (no parent prefix — starts with "lat.md/")
149
- const idx = clean.indexOf('/lat.md/');
150
- if (idx !== -1)
151
- subProjects.add(clean.slice(0, idx));
152
- }
153
- return [...subProjects];
154
- }
155
- /** Find static UI exports so generated JSON and bundles never become code refs. */
156
- async function findGeneratedOutputs(projectRoot) {
157
- const out = await tryExec('rg', ['--files', '--hidden', '--glob', '**/.lat-ui-build', '.'], projectRoot);
158
- if (!out)
159
- return [];
160
- return [
161
- ...new Set(out
162
- .split('\n')
163
- .filter(Boolean)
164
- .map((line) => toPosix(line).replace(/^\.\//, ''))
165
- .filter((line) => line.endsWith('/.lat-ui-build'))
166
- .map((line) => posix.dirname(line))),
167
- ];
168
- }
169
- /** Build rg glob exclusion args. */
170
- function rgExcludeArgs(subProjects, generatedOutputs) {
171
- const args = [];
172
- for (const dir of EXCLUDE_DIRS)
173
- args.push('--glob', `!${dir}/`);
174
- for (const glob of EXCLUDE_GLOBS)
175
- args.push('--glob', `!${glob}`);
176
- for (const sp of subProjects)
177
- args.push('--glob', `!${sp}/`);
178
- for (const output of generatedOutputs)
179
- args.push('--glob', `!${output}/`);
180
- return args;
181
- }
182
- /**
183
- * Try scanning with ripgrep. Returns parsed refs and scanned file list, or null
184
- * if rg is not available. rg respects .gitignore by default; we add glob
185
- * exclusions for lat.md/, .claude/, *.md files, and sub-projects.
186
- */
187
- async function tryRipgrep(projectRoot) {
188
- // Detect sub-projects first so we can exclude them from all rg calls
189
- const subProjects = await findSubProjects(projectRoot);
190
- const generatedOutputs = await findGeneratedOutputs(projectRoot);
191
- const excludes = rgExcludeArgs(subProjects, generatedOutputs);
192
- // Search for @lat refs
193
- const searchArgs = [
194
- '--no-heading',
195
- '--line-number',
196
- '--with-filename',
197
- ...excludes,
198
- '@lat:.*\\[\\[',
199
- '.',
200
- ];
201
- const out = await tryExec('rg', searchArgs, projectRoot);
202
- if (out === null)
203
- return null;
204
- const { refs } = parseGrepOutput(out);
205
- // List all scanned files (for stats) — rg --files is fast
206
- const filesOut = await tryExec('rg', ['--files', ...excludes, '.'], projectRoot);
207
- const files = (filesOut || '')
208
- .split('\n')
209
- .filter(Boolean)
210
- .map((f) => {
211
- const clean = toPosix(f).replace(/^\.\//, '');
212
- return join(projectRoot, clean);
213
- });
214
- return { refs, files };
215
- }
216
- /**
217
- * Parse rg output lines (file:line:content) into CodeRef entries.
218
- */
219
- function parseGrepOutput(output) {
220
- const refs = [];
221
- if (!output.trim())
222
- return { refs };
223
- for (const line of output.split('\n')) {
224
- if (!line)
225
- continue;
226
- // Format: ./path/to/file:linenum:content
227
- const firstColon = line.indexOf(':');
228
- if (firstColon === -1)
229
- continue;
230
- const secondColon = line.indexOf(':', firstColon + 1);
231
- if (secondColon === -1)
232
- continue;
233
- // rg emits native separators (`\` on Windows); normalize to POSIX so the
234
- // stored path matches wiki-link and TS-fallback conventions. This also
235
- // turns a Windows `.\` prefix into `./` for the strip below.
236
- let filePath = toPosix(line.slice(0, firstColon));
237
- const lineNum = parseInt(line.slice(firstColon + 1, secondColon), 10);
238
- const content = line.slice(secondColon + 1);
239
- if (isNaN(lineNum))
240
- continue;
241
- // Strip leading ./ from path
242
- if (filePath.startsWith('./'))
243
- filePath = filePath.slice(2);
244
- // Extract targets using the same regex and literal-span filtering as the
245
- // TS fallback, so both scan paths agree regardless of whether ripgrep is
246
- // installed.
247
- for (const target of extractRefsFromLine(content)) {
248
- refs.push({ target, file: filePath, line: lineNum });
249
- }
250
- }
251
- return { refs };
252
- }
253
- /**
254
- * TypeScript fallback: read every file and scan for @lat refs.
255
- */
256
- async function scanWithTs(files, projectRoot) {
257
- const refs = [];
258
- for (const file of files) {
259
- let content;
260
- try {
261
- content = await readFile(file, 'utf-8');
262
- }
263
- catch (err) {
264
- process.stderr.write(`Error: failed to read ${file}: ${err.message}\n`);
265
- continue;
266
- }
267
- const lines = content.split('\n');
268
- for (let i = 0; i < lines.length; i++) {
269
- for (const target of extractRefsFromLine(lines[i])) {
270
- refs.push({
271
- target,
272
- file: toPosix(relative(projectRoot, file)),
273
- line: i + 1,
274
- });
275
- }
276
- }
277
- }
278
- return refs;
279
- }
280
- /** Check whether ripgrep (`rg`) is available on PATH. */
281
- export async function hasRipgrep() {
282
- const result = await tryExec('rg', ['--version'], '.');
283
- return result !== null;
284
- }
285
- export async function scanCodeRefs(projectRoot) {
286
- // Fast path: use rg for both searching and file listing
287
- // _LAT_DISABLE_RG is a test-only escape hatch to force the TS fallback
288
- if (process.env._LAT_DISABLE_RG !== '1') {
289
- const rgResult = await tryRipgrep(projectRoot);
290
- if (rgResult !== null) {
291
- return { refs: rgResult.refs, files: rgResult.files, usedRg: true };
292
- }
293
- }
294
- // Fallback: walk files ourselves and scan with TS
295
- const files = await walkFiles(projectRoot);
296
- const refs = await scanWithTs(files, projectRoot);
297
- return { refs, files, usedRg: false };
298
- }
@@ -1,29 +0,0 @@
1
- export declare function getConfigDir(): string;
2
- export declare function getConfigPath(): string;
3
- export type LatConfig = {
4
- llm_key?: string;
5
- /**
6
- * Per-repo embedding backend preference, keyed by absolute lat.md dir. Durable
7
- * (survives deletion of the regenerable `.cache`), so a repo explicitly
8
- * switched to local stays local even after a cache wipe or fresh clone.
9
- */
10
- repos?: Record<string, {
11
- embedding?: 'local';
12
- }>;
13
- };
14
- export declare function readConfig(): LatConfig;
15
- export declare function writeConfig(config: LatConfig): void;
16
- /** Durable per-repo backend choice, or undefined if none recorded. */
17
- export declare function getRepoEmbedding(latDir: string): 'local' | undefined;
18
- /** Record (or clear, with `null`) the durable per-repo backend choice. */
19
- export declare function setRepoEmbedding(latDir: string, embedding: 'local' | null): void;
20
- /**
21
- * Returns the LLM key from (in priority order):
22
- * 1. LAT_LLM_KEY environment variable
23
- * 2. LAT_LLM_KEY_FILE — path to a file containing the key
24
- * 3. LAT_LLM_KEY_HELPER — shell command that prints the key
25
- * 4. llm_key field in ~/.config/lat/config.json
26
- *
27
- * Returns undefined if none is set.
28
- */
29
- export declare function getLlmKey(): string | undefined;
@@ -1,83 +0,0 @@
1
- import { execSync } from 'node:child_process';
2
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
3
- import { join, resolve } from 'node:path';
4
- import xdg from '@folder/xdg';
5
- // ── XDG config directory ────────────────────────────────────────────
6
- export function getConfigDir() {
7
- return join(xdg().config, 'lat');
8
- }
9
- export function getConfigPath() {
10
- return join(getConfigDir(), 'config.json');
11
- }
12
- export function readConfig() {
13
- const configPath = getConfigPath();
14
- if (!existsSync(configPath))
15
- return {};
16
- try {
17
- return JSON.parse(readFileSync(configPath, 'utf-8'));
18
- }
19
- catch (err) {
20
- process.stderr.write(`Error: failed to parse config ${configPath}: ${err.message}\n`);
21
- process.exit(1);
22
- }
23
- }
24
- export function writeConfig(config) {
25
- const dir = getConfigDir();
26
- mkdirSync(dir, { recursive: true });
27
- writeFileSync(getConfigPath(), JSON.stringify(config, null, 2) + '\n');
28
- }
29
- // ── Per-repo embedding backend preference ───────────────────────────
30
- /** Durable per-repo backend choice, or undefined if none recorded. */
31
- export function getRepoEmbedding(latDir) {
32
- return readConfig().repos?.[resolve(latDir)]?.embedding;
33
- }
34
- /** Record (or clear, with `null`) the durable per-repo backend choice. */
35
- export function setRepoEmbedding(latDir, embedding) {
36
- const key = resolve(latDir);
37
- const config = readConfig();
38
- const repos = config.repos ?? {};
39
- if (embedding === null)
40
- delete repos[key];
41
- else
42
- repos[key] = { embedding };
43
- config.repos = repos;
44
- writeConfig(config);
45
- }
46
- // ── Centralized LLM key resolution ─────────────────────────────────
47
- /**
48
- * Returns the LLM key from (in priority order):
49
- * 1. LAT_LLM_KEY environment variable
50
- * 2. LAT_LLM_KEY_FILE — path to a file containing the key
51
- * 3. LAT_LLM_KEY_HELPER — shell command that prints the key
52
- * 4. llm_key field in ~/.config/lat/config.json
53
- *
54
- * Returns undefined if none is set.
55
- */
56
- export function getLlmKey() {
57
- const envKey = process.env.LAT_LLM_KEY;
58
- if (envKey)
59
- return envKey;
60
- const file = process.env.LAT_LLM_KEY_FILE;
61
- if (file) {
62
- const content = readFileSync(file, 'utf-8').trim();
63
- if (!content) {
64
- throw new Error(`LAT_LLM_KEY_FILE (${file}) is empty.`);
65
- }
66
- return content;
67
- }
68
- const helper = process.env.LAT_LLM_KEY_HELPER;
69
- if (helper) {
70
- const result = execSync(helper, {
71
- encoding: 'utf-8',
72
- timeout: 10_000,
73
- }).trim();
74
- if (!result) {
75
- throw new Error('LAT_LLM_KEY_HELPER command returned an empty string.');
76
- }
77
- return result;
78
- }
79
- const config = readConfig();
80
- if (config.llm_key)
81
- return config.llm_key;
82
- return undefined;
83
- }
@@ -1,23 +0,0 @@
1
- export type Styler = {
2
- bold: (s: string) => string;
3
- dim: (s: string) => string;
4
- red: (s: string) => string;
5
- cyan: (s: string) => string;
6
- white: (s: string) => string;
7
- green: (s: string) => string;
8
- yellow: (s: string) => string;
9
- boldWhite: (s: string) => string;
10
- };
11
- export declare const plainStyler: Styler;
12
- export type CmdContext = {
13
- latDir: string;
14
- projectRoot: string;
15
- styler: Styler;
16
- mode: 'cli' | 'mcp';
17
- /** The check target was supplied explicitly instead of discovered as lat.md. */
18
- headless?: boolean;
19
- };
20
- export type CmdResult = {
21
- output: string;
22
- isError?: boolean;
23
- };
@@ -1,11 +0,0 @@
1
- const identity = (s) => s;
2
- export const plainStyler = {
3
- bold: identity,
4
- dim: identity,
5
- red: identity,
6
- cyan: identity,
7
- white: identity,
8
- green: identity,
9
- yellow: identity,
10
- boldWhite: identity,
11
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * mdast-util extension to turn wiki-link micromark tokens into mdast nodes.
3
- */
4
- import type { Extension } from 'mdast-util-from-markdown';
5
- export declare function wikiLinkFromMarkdown(): Extension;
@@ -1,34 +0,0 @@
1
- /**
2
- * mdast-util extension to turn wiki-link micromark tokens into mdast nodes.
3
- */
4
- function enterWikiLink(token) {
5
- const node = {
6
- type: 'wikiLink',
7
- value: '',
8
- data: { alias: null },
9
- };
10
- this.enter(node, token);
11
- }
12
- function exitWikiLinkTarget(token) {
13
- const target = this.sliceSerialize(token);
14
- const node = this.stack[this.stack.length - 1];
15
- node.value = target;
16
- }
17
- function exitWikiLinkAlias(token) {
18
- const alias = this.sliceSerialize(token);
19
- const node = this.stack[this.stack.length - 1];
20
- node.data.alias = alias;
21
- }
22
- function exitWikiLink(token) {
23
- this.exit(token);
24
- }
25
- export function wikiLinkFromMarkdown() {
26
- return {
27
- enter: { wikiLink: enterWikiLink },
28
- exit: {
29
- wikiLinkTarget: exitWikiLinkTarget,
30
- wikiLinkAlias: exitWikiLinkAlias,
31
- wikiLink: exitWikiLink,
32
- },
33
- };
34
- }
@@ -1,4 +0,0 @@
1
- export { wikiLinkSyntax } from './syntax.js';
2
- export { wikiLinkFromMarkdown } from './from-markdown.js';
3
- export { wikiLinkToMarkdown } from './to-markdown.js';
4
- export type { WikiLink } from './types.js';
@@ -1,3 +0,0 @@
1
- export { wikiLinkSyntax } from './syntax.js';
2
- export { wikiLinkFromMarkdown } from './from-markdown.js';
3
- export { wikiLinkToMarkdown } from './to-markdown.js';
@@ -1,14 +0,0 @@
1
- /**
2
- * Micromark syntax extension for wiki links: [[target]] and [[target|alias]].
3
- *
4
- * Produces the following token types:
5
- * - wikiLink (the entire construct)
6
- * - wikiLinkMarker ([[ and ]])
7
- * - wikiLinkData (everything between markers)
8
- * - wikiLinkTarget (the target portion)
9
- * - wikiLinkAliasMarker (the | divider)
10
- * - wikiLinkAlias (the alias portion)
11
- */
12
- import type { Extension } from 'micromark-util-types';
13
- import './types.js';
14
- export declare function wikiLinkSyntax(): Extension;
@@ -1,121 +0,0 @@
1
- /**
2
- * Micromark syntax extension for wiki links: [[target]] and [[target|alias]].
3
- *
4
- * Produces the following token types:
5
- * - wikiLink (the entire construct)
6
- * - wikiLinkMarker ([[ and ]])
7
- * - wikiLinkData (everything between markers)
8
- * - wikiLinkTarget (the target portion)
9
- * - wikiLinkAliasMarker (the | divider)
10
- * - wikiLinkAlias (the alias portion)
11
- */
12
- import './types.js';
13
- const ALIAS_DIVIDER = '|';
14
- const OPEN = '[[';
15
- const CLOSE = ']]';
16
- function tokenize(effects, ok, nok) {
17
- let openCursor = 0;
18
- let closeCursor = 0;
19
- let aliasCursor = 0;
20
- let hasData = false;
21
- let hasAlias = false;
22
- return start;
23
- function start(code) {
24
- if (code !== OPEN.charCodeAt(openCursor))
25
- return nok(code);
26
- effects.enter('wikiLink');
27
- effects.enter('wikiLinkMarker');
28
- return consumeOpen(code);
29
- }
30
- function consumeOpen(code) {
31
- if (openCursor === OPEN.length) {
32
- effects.exit('wikiLinkMarker');
33
- return consumeDataStart(code);
34
- }
35
- if (code !== OPEN.charCodeAt(openCursor))
36
- return nok(code);
37
- effects.consume(code);
38
- openCursor++;
39
- return consumeOpen;
40
- }
41
- function consumeDataStart(code) {
42
- if (code === null || code < -2)
43
- return nok(code);
44
- effects.enter('wikiLinkData');
45
- effects.enter('wikiLinkTarget');
46
- return consumeTarget(code);
47
- }
48
- function consumeTarget(code) {
49
- if (code === ALIAS_DIVIDER.charCodeAt(aliasCursor)) {
50
- if (!hasData)
51
- return nok(code);
52
- effects.exit('wikiLinkTarget');
53
- effects.enter('wikiLinkAliasMarker');
54
- return consumeAliasMarker(code);
55
- }
56
- if (code === CLOSE.charCodeAt(closeCursor)) {
57
- if (!hasData)
58
- return nok(code);
59
- effects.exit('wikiLinkTarget');
60
- effects.exit('wikiLinkData');
61
- effects.enter('wikiLinkMarker');
62
- return consumeClose(code);
63
- }
64
- // No line endings or EOF inside wiki links
65
- if (code === null || code < -2)
66
- return nok(code);
67
- if (code !== -2 && code !== -1 && code !== 32) {
68
- hasData = true;
69
- }
70
- effects.consume(code);
71
- return consumeTarget;
72
- }
73
- function consumeAliasMarker(code) {
74
- if (aliasCursor === ALIAS_DIVIDER.length) {
75
- effects.exit('wikiLinkAliasMarker');
76
- effects.enter('wikiLinkAlias');
77
- return consumeAlias(code);
78
- }
79
- if (code !== ALIAS_DIVIDER.charCodeAt(aliasCursor))
80
- return nok(code);
81
- effects.consume(code);
82
- aliasCursor++;
83
- return consumeAliasMarker;
84
- }
85
- function consumeAlias(code) {
86
- if (code === CLOSE.charCodeAt(closeCursor)) {
87
- if (!hasAlias)
88
- return nok(code);
89
- effects.exit('wikiLinkAlias');
90
- effects.exit('wikiLinkData');
91
- effects.enter('wikiLinkMarker');
92
- return consumeClose(code);
93
- }
94
- if (code === null || code < -2)
95
- return nok(code);
96
- if (code !== -2 && code !== -1 && code !== 32) {
97
- hasAlias = true;
98
- }
99
- effects.consume(code);
100
- return consumeAlias;
101
- }
102
- function consumeClose(code) {
103
- if (closeCursor === CLOSE.length) {
104
- effects.exit('wikiLinkMarker');
105
- effects.exit('wikiLink');
106
- return ok(code);
107
- }
108
- if (code !== CLOSE.charCodeAt(closeCursor))
109
- return nok(code);
110
- effects.consume(code);
111
- closeCursor++;
112
- return consumeClose;
113
- }
114
- }
115
- export function wikiLinkSyntax() {
116
- return {
117
- text: {
118
- 91: { tokenize }, // '[' character code
119
- },
120
- };
121
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * mdast-util extension to serialize wiki-link nodes back to markdown.
3
- */
4
- import type { Options } from 'mdast-util-to-markdown';
5
- export declare function wikiLinkToMarkdown(): Options;
@@ -1,28 +0,0 @@
1
- /**
2
- * mdast-util extension to serialize wiki-link nodes back to markdown.
3
- */
4
- function handler(node, _parent, state, _info) {
5
- const exit = state.enter('wikiLink');
6
- const target = state.safe(node.value, { before: '[', after: ']' });
7
- let value;
8
- if (node.data.alias) {
9
- const alias = state.safe(node.data.alias, { before: '[', after: ']' });
10
- value = `[[${target}|${alias}]]`;
11
- }
12
- else {
13
- value = `[[${target}]]`;
14
- }
15
- exit();
16
- return value;
17
- }
18
- export function wikiLinkToMarkdown() {
19
- return {
20
- unsafe: [
21
- { character: '[', inConstruct: ['phrasing', 'label', 'reference'] },
22
- { character: ']', inConstruct: ['label', 'reference'] },
23
- ],
24
- handlers: {
25
- wikiLink: handler,
26
- },
27
- };
28
- }