@plebeiantech/lat.md 0.12.3-fork.9 → 0.13.4-fork.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -3
- package/dist/src/cli/agent-invocation.d.ts +6 -0
- package/dist/src/cli/agent-invocation.js +23 -0
- package/dist/src/cli/checklist-menu.d.ts +2 -1
- package/dist/src/cli/checklist-menu.js +3 -2
- package/dist/src/cli/fork-instructions.d.ts +1 -0
- package/dist/src/cli/fork-instructions.js +8 -32
- package/dist/src/cli/fork-scaffold.js +2 -2
- package/dist/src/cli/graph.d.ts +1 -1
- package/dist/src/cli/hook.d.ts +26 -0
- package/dist/src/cli/hook.js +115 -64
- package/dist/src/cli/index.js +178 -70
- package/dist/src/cli/init-preferences.d.ts +4 -0
- package/dist/src/cli/init-preferences.js +36 -0
- package/dist/src/cli/init.d.ts +2 -1
- package/dist/src/cli/init.js +100 -60
- package/dist/src/cli/reindex.d.ts +1 -1
- package/dist/src/cli/reindex.js +7 -10
- package/dist/src/cli/search.d.ts +14 -4
- package/dist/src/cli/search.js +115 -101
- package/dist/src/cli/ui-build-server.d.ts +12 -0
- package/dist/src/cli/ui-build-server.js +26 -0
- package/dist/src/cli/ui-build.d.ts +1 -1
- package/dist/src/cli/ui-build.js +1 -1
- package/dist/src/cli/ui.d.ts +1 -1
- package/dist/src/cli/ui.js +1 -1
- package/dist/src/cli/wiki.d.ts +12 -0
- package/dist/src/cli/wiki.js +85 -0
- package/dist/src/fork/antigravity-hook.d.ts +47 -0
- package/dist/src/fork/antigravity-hook.js +424 -0
- package/dist/src/fork/antigravity-init.d.ts +17 -0
- package/dist/src/fork/antigravity-init.js +124 -0
- package/dist/src/fork/upstream-drift.js +1 -1
- package/dist/src/fork/upstream-guard.d.ts +1 -1
- package/dist/src/fork/upstream-guard.js +8 -7
- package/dist/src/graph-export.js +7 -7
- package/dist/src/knowledge/index.js +2 -2
- package/dist/src/mcp/server.js +34 -18
- package/dist/src/search/cache.d.ts +3 -0
- package/dist/src/search/cache.js +104 -0
- package/dist/src/search/chunks.d.ts +23 -0
- package/dist/src/search/chunks.js +200 -0
- package/dist/src/search/db.d.ts +28 -16
- package/dist/src/search/db.js +100 -40
- package/dist/src/search/embedder.d.ts +2 -1
- package/dist/src/search/embedder.js +7 -6
- package/dist/src/search/index.d.ts +6 -2
- package/dist/src/search/index.js +176 -70
- package/dist/src/search/lexical.d.ts +6 -0
- package/dist/src/search/lexical.js +36 -0
- package/dist/src/search/lock.d.ts +5 -0
- package/dist/src/search/lock.js +45 -0
- package/dist/src/search/query.d.ts +26 -0
- package/dist/src/search/query.js +103 -0
- package/dist/src/search/search.d.ts +16 -7
- package/dist/src/search/search.js +165 -21
- package/dist/src/search/types.d.ts +15 -0
- package/dist/src/view/client/assets/GraphView-D_xnk0bP.js +456 -0
- package/dist/src/view/client/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/src/view/client/assets/MarkdownEditor-bjqt_FoF.js +28 -0
- package/dist/src/view/client/assets/OrbitControls-DwcpQNja.js +1 -0
- package/dist/src/view/client/assets/STLLoader-CLWTKt5i.js +1 -0
- package/dist/src/view/client/assets/_commonjsHelpers-CqkleIqs.js +1 -0
- package/dist/src/view/client/assets/abnfDiagram-VCTEODGH-kWGvtRnL.js +1 -0
- package/dist/src/view/client/assets/arc-BPAFd7cP.js +1 -0
- package/dist/src/view/client/assets/architectureDiagram-5GKGNRK7-CsY39oIR.js +36 -0
- package/dist/src/view/client/assets/blockDiagram-I7D4REHJ-DHGBG7BJ.js +129 -0
- package/dist/src/view/client/assets/c4Diagram-7LVT6UL2-vywK4eb7.js +38 -0
- package/dist/src/view/client/assets/channel-CX71L_qV.js +1 -0
- package/dist/src/view/client/assets/chunk-2Q5K7J3B-Do3Hz_ci.js +1 -0
- package/dist/src/view/client/assets/chunk-5VM5RSS4-B5R1lSeY.js +15 -0
- package/dist/src/view/client/assets/chunk-F27PBJKO-Dm55FM_W.js +1 -0
- package/dist/src/view/client/assets/chunk-IMKFNOWR-ChptrvvM.js +231 -0
- package/dist/src/view/client/assets/chunk-JWPE2WC7-BRQBjrKS.js +1 -0
- package/dist/src/view/client/assets/chunk-POPQ4Y6H-CainVZIL.js +1 -0
- package/dist/src/view/client/assets/chunk-SVP7TREG-DsKsNGmM.js +88 -0
- package/dist/src/view/client/assets/chunk-TICWLB2K-BctkMcJc.js +206 -0
- package/dist/src/view/client/assets/chunk-XXDRQBXY-BN7SgOUT.js +1 -0
- package/dist/src/view/client/assets/classDiagram-ZZMXUADV-B1VyU6zO.js +1 -0
- package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-B1VyU6zO.js +1 -0
- package/dist/src/view/client/assets/cose-bilkent-JH36ORCC-BszzwrMe.js +1 -0
- package/dist/src/view/client/assets/cynefin-OW5HDTMX-CdRyAkPs.js +166 -0
- package/dist/src/view/client/assets/cynefinDiagram-5FMLGOSQ-BLvKPZ1u.js +62 -0
- package/dist/src/view/client/assets/cytoscape.esm-DzSz-X2X.js +321 -0
- package/dist/src/view/client/assets/dagre-GXQ25YYZ-V68w_l65.js +4 -0
- package/dist/src/view/client/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/src/view/client/assets/diagram-S7CK7UJ4-C2i4eEMg.js +30 -0
- package/dist/src/view/client/assets/diagram-UQ7AKVKN-BiwWh5jC.js +41 -0
- package/dist/src/view/client/assets/diagram-VSXAHHWV-hkKR_vyS.js +3 -0
- package/dist/src/view/client/assets/diagram-VX7I27RA-DzRCSMAc.js +24 -0
- package/dist/src/view/client/assets/diagram-Z3DM3KII-fhSFPxyK.js +24 -0
- package/dist/src/view/client/assets/ebnfDiagram-PWID7BFC-CCEUDKSA.js +1 -0
- package/dist/src/view/client/assets/erDiagram-RLTQ6QDP-FJ2IMyTi.js +99 -0
- package/dist/src/view/client/assets/flowDiagram-HODETNUW-BvasdLeK.js +168 -0
- package/dist/src/view/client/assets/ganttDiagram-EL5Y4UJY-CiwkBZvY.js +292 -0
- package/dist/src/view/client/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/src/view/client/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/src/view/client/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/src/view/client/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/dist/src/view/client/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/dist/src/view/client/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/src/view/client/assets/gitGraphDiagram-WWUBYQGX-DYlP2_js.js +106 -0
- package/dist/src/view/client/assets/index-BnENo9bV.js +1 -0
- package/dist/src/view/client/assets/index-CQ7EOox7.css +1 -0
- package/dist/src/view/client/assets/index-CynNDkxt.js +13 -0
- package/dist/src/view/client/assets/infoDiagram-27XIBGKW-DRPB2c48.js +2 -0
- package/dist/src/view/client/assets/init-Gi6I4Gst.js +1 -0
- package/dist/src/view/client/assets/ishikawaDiagram-5VMMS53U-8VV429Cv.js +70 -0
- package/dist/src/view/client/assets/journeyDiagram-3NMN7TZE-Dzmwnf83.js +139 -0
- package/dist/src/view/client/assets/kanban-definition-UXKFOSKX-pYyZZ1i-.js +89 -0
- package/dist/src/view/client/assets/katex-HP8lGamR.js +257 -0
- package/dist/src/view/client/assets/layout-GF9k6yGo.js +1 -0
- package/dist/src/view/client/assets/linear-Yt2sSOYV.js +1 -0
- package/dist/src/view/client/assets/logo-RR_KBOAT.svg +149 -0
- package/dist/src/view/client/assets/maplibre-gl-CDX6Zuow.js +800 -0
- package/dist/src/view/client/assets/mermaid.core-ChWYCHN0.js +310 -0
- package/dist/src/view/client/assets/mindmap-definition-YA3MSWOX-Cc4fQvf1.js +96 -0
- package/dist/src/view/client/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/src/view/client/assets/pegDiagram-XKGWAZYB-C0SsB8bZ.js +1 -0
- package/dist/src/view/client/assets/pieDiagram-E7YTZNPT-DIJpqERZ.js +39 -0
- package/dist/src/view/client/assets/quadrantDiagram-AXDQQJYC--d-gl6j-.js +7 -0
- package/dist/src/view/client/assets/railroadDiagram-O6MQD6OU-BQxwTt7z.js +1 -0
- package/dist/src/view/client/assets/requirementDiagram-BXWQKSXE-B_oTeD2A.js +84 -0
- package/dist/src/view/client/assets/sankeyDiagram-P5KCCOFB-DLukmE8X.js +40 -0
- package/dist/src/view/client/assets/sequenceDiagram-WJ2MYXX4-BNjVB2sc.js +162 -0
- package/dist/src/view/client/assets/sizeCapture-INFHLROL-BZecQTOw.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-D77RDMKH-Bu1urvXC.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-5pc_697G.js +1 -0
- package/dist/src/view/client/assets/swimlanes-42K2YHIH-bLAlcepB.js +1 -0
- package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-BbOpZjpp.js +8 -0
- package/dist/src/view/client/assets/three.module-PDSP0dbZ.js +4108 -0
- package/dist/src/view/client/assets/timeline-definition-24CTP7MA-tbwCNvcA.js +120 -0
- package/dist/src/view/client/assets/vennDiagram-4TSXK5OY-D8U8Fk0N.js +34 -0
- package/dist/src/view/client/assets/wardleyDiagram-VM6X3IG4-LHBVIeNb.js +78 -0
- package/dist/src/view/client/assets/xychartDiagram-S5SC5T6Z-CN4tfaFV.js +7 -0
- package/dist/src/view/client/index.html +2 -2
- package/dist/src/view/client-shell.d.ts +2 -0
- package/dist/src/view/client-shell.js +5 -0
- package/dist/src/view/diagnostics.d.ts +3 -2
- package/dist/src/view/diagnostics.js +49 -58
- package/dist/src/view/document-edit.d.ts +8 -0
- package/dist/src/view/document-edit.js +25 -0
- package/dist/src/view/document-route.d.ts +14 -0
- package/dist/src/view/document-route.js +137 -0
- package/dist/src/view/document-tree.d.ts +18 -0
- package/dist/src/view/document-tree.js +139 -0
- package/dist/src/view/external-document-tree.d.ts +3 -0
- package/dist/src/view/external-document-tree.js +674 -0
- package/dist/src/view/git-diff.js +202 -2
- package/dist/src/view/git.js +1 -1
- package/dist/src/view/graph.d.ts +4 -3
- package/dist/src/view/graph.js +100 -9
- package/dist/src/view/highlight.d.ts +10 -2
- package/dist/src/view/highlight.js +50648 -3166
- package/dist/src/view/markdown.d.ts +3 -2
- package/dist/src/view/markdown.js +256 -54
- package/dist/src/view/preindexed-search.d.ts +15 -0
- package/dist/src/view/preindexed-search.js +25 -0
- package/dist/src/view/protocol.d.ts +53 -7
- package/dist/src/view/publication.d.ts +2 -0
- package/dist/src/view/publication.js +78 -0
- package/dist/src/view/references.d.ts +11 -26
- package/dist/src/view/references.js +121 -112
- package/dist/src/view/repository.d.ts +14 -4
- package/dist/src/view/repository.js +260 -19
- package/dist/src/view/request-security.d.ts +5 -0
- package/dist/src/view/request-security.js +46 -0
- package/dist/src/view/search-result.d.ts +4 -0
- package/dist/src/view/search-result.js +25 -0
- package/dist/src/view/search.d.ts +7 -2
- package/dist/src/view/search.js +23 -34
- package/dist/src/view/server-build.d.ts +21 -0
- package/dist/src/view/server-build.js +145 -0
- package/dist/src/view/server-deployment.d.ts +31 -0
- package/dist/src/view/server-deployment.js +123 -0
- package/dist/src/view/server-index-worker.d.ts +6 -0
- package/dist/src/view/server-index-worker.js +14 -0
- package/dist/src/view/server.d.ts +11 -2
- package/dist/src/view/server.js +245 -73
- package/dist/src/view/source-target.d.ts +2 -0
- package/dist/src/view/source-target.js +49 -8
- package/dist/src/view/static-build.d.ts +18 -2
- package/dist/src/view/static-build.js +449 -110
- package/dist/src/view/static-protocol.d.ts +26 -2
- package/dist/src/view/static-protocol.js +5 -0
- package/dist/src/view/store.d.ts +20 -3
- package/dist/src/view/store.js +304 -48
- package/dist/src/view/table-of-contents.d.ts +2 -2
- package/dist/src/view/table-of-contents.js +2 -22
- package/dist/src/view/vercel-build.d.ts +24 -0
- package/dist/src/view/vercel-build.js +152 -0
- package/dist/src/view/vercel-server-build.d.ts +10 -0
- package/dist/src/view/vercel-server-build.js +61 -0
- package/dist/src/wiki/catalog.d.ts +21 -0
- package/dist/src/wiki/catalog.js +256 -0
- package/dist/src/wiki/publish.d.ts +27 -0
- package/dist/src/wiki/publish.js +265 -0
- package/dist/src/wiki/render.d.ts +20 -0
- package/dist/src/wiki/render.js +163 -0
- package/dist/src/wiki/transform.d.ts +7 -0
- package/dist/src/wiki/transform.js +264 -0
- package/dist/vendor/lat.md-server/cli.d.ts +2 -0
- package/dist/vendor/lat.md-server/cli.js +12 -0
- package/dist/vendor/lat.md-server/index.d.ts +38 -0
- package/dist/vendor/lat.md-server/index.js +128 -0
- package/package.json +68 -22
- package/plugins/lat-md/README.md +61 -0
- package/plugins/lat-md/hooks.json +38 -0
- package/plugins/lat-md/plugin.json +9 -0
- package/plugins/lat-md/rules/AGENTS.md +344 -0
- package/plugins/lat-md/skills/lat-md/SKILL.md +210 -0
- package/plugins/lat-md/skills/lat-md-conventions/SKILL.md +226 -0
- package/templates/AGENTS.md +26 -7
- package/templates/cursor-rules.md +23 -7
- package/templates/fork/conventions.md +133 -11
- package/templates/opencode-plugin.ts +9 -9
- package/templates/pi-extension.ts +11 -11
- package/templates/skill/SKILL.md +35 -3
- package/dist/src/cli/check-coverage.d.ts +0 -2
- package/dist/src/cli/check-coverage.js +0 -71
- package/dist/src/cli/check-frontmatter.d.ts +0 -12
- package/dist/src/cli/check-frontmatter.js +0 -44
- package/dist/src/cli/check-mode.d.ts +0 -21
- package/dist/src/cli/check-mode.js +0 -364
- package/dist/src/cli/check-status.d.ts +0 -74
- package/dist/src/cli/check-status.js +0 -217
- package/dist/src/cli/check.d.ts +0 -45
- package/dist/src/cli/check.js +0 -781
- package/dist/src/cli/context.d.ts +0 -11
- package/dist/src/cli/context.js +0 -58
- package/dist/src/cli/expand.d.ts +0 -8
- package/dist/src/cli/expand.js +0 -94
- package/dist/src/cli/gen-index.d.ts +0 -45
- package/dist/src/cli/gen-index.js +0 -235
- package/dist/src/cli/link-scheme.d.ts +0 -54
- package/dist/src/cli/link-scheme.js +0 -101
- package/dist/src/cli/locate.d.ts +0 -2
- package/dist/src/cli/locate.js +0 -17
- package/dist/src/cli/refs.d.ts +0 -22
- package/dist/src/cli/refs.js +0 -229
- package/dist/src/cli/section.d.ts +0 -43
- package/dist/src/cli/section.js +0 -252
- package/dist/src/cli/select-menu.d.ts +0 -13
- package/dist/src/cli/select-menu.js +0 -100
- package/dist/src/code-refs.d.ts +0 -17
- package/dist/src/code-refs.js +0 -298
- package/dist/src/config.d.ts +0 -29
- package/dist/src/config.js +0 -83
- package/dist/src/context.d.ts +0 -23
- package/dist/src/context.js +0 -11
- package/dist/src/extensions/wiki-link/from-markdown.d.ts +0 -5
- package/dist/src/extensions/wiki-link/from-markdown.js +0 -34
- package/dist/src/extensions/wiki-link/index.d.ts +0 -4
- package/dist/src/extensions/wiki-link/index.js +0 -3
- package/dist/src/extensions/wiki-link/syntax.d.ts +0 -14
- package/dist/src/extensions/wiki-link/syntax.js +0 -121
- package/dist/src/extensions/wiki-link/to-markdown.d.ts +0 -5
- package/dist/src/extensions/wiki-link/to-markdown.js +0 -28
- package/dist/src/extensions/wiki-link/types.d.ts +0 -34
- package/dist/src/format.d.ts +0 -8
- package/dist/src/format.js +0 -43
- package/dist/src/init-version.d.ts +0 -10
- package/dist/src/init-version.js +0 -49
- package/dist/src/lattice.d.ts +0 -109
- package/dist/src/lattice.js +0 -817
- package/dist/src/parser.d.ts +0 -3
- package/dist/src/parser.js +0 -18
- package/dist/src/source-parser.d.ts +0 -27
- package/dist/src/source-parser.js +0 -916
- package/dist/src/untrusted.d.ts +0 -18
- package/dist/src/untrusted.js +0 -93
- package/dist/src/view/client/assets/index-C3iaZyYT.css +0 -1
- package/dist/src/view/client/assets/index-KWi67IMz.js +0 -334
- package/dist/src/view/client/assets/logo-CNF8zs47.svg +0 -182
- package/dist/src/walk.d.ts +0 -18
- package/dist/src/walk.js +0 -27
- /package/dist/src/{extensions/wiki-link → search}/types.js +0 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { execFile, execFileSync } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { basename, dirname, isAbsolute, join } from 'node:path';
|
|
6
|
+
import { promisify } from 'node:util';
|
|
7
|
+
import { buildWikiCatalog } from './catalog.js';
|
|
8
|
+
import { transformWikiCatalog } from './transform.js';
|
|
9
|
+
import { renderWikiBundle, writeWikiBundle } from './render.js';
|
|
10
|
+
const execFileAsync = promisify(execFile);
|
|
11
|
+
const GITHUB_HTTPS_RE = /^https:\/\/github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/;
|
|
12
|
+
const GITHUB_SSH_RE = /^(?:git@github\.com:|ssh:\/\/git@github\.com\/)([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/;
|
|
13
|
+
const GITHUB_SLUG_RE = /^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?$/;
|
|
14
|
+
function redactCredentials(url) {
|
|
15
|
+
return url.replace(/:\/\/[^@/]+@/, '://***@');
|
|
16
|
+
}
|
|
17
|
+
function assertNotUpstream(target) {
|
|
18
|
+
const lower = target.trim().toLowerCase();
|
|
19
|
+
if (lower === 'upstream' || lower.includes('vercel-labs/lat.md')) {
|
|
20
|
+
throw new Error(`Refusing to target upstream repository (vercel-labs/lat.md). Specify your fork repository.`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function parseGitHubUrlOrSlug(target) {
|
|
24
|
+
const httpsMatch = target.match(GITHUB_HTTPS_RE);
|
|
25
|
+
if (httpsMatch) {
|
|
26
|
+
return { owner: httpsMatch[1], repo: httpsMatch[2], isSsh: false };
|
|
27
|
+
}
|
|
28
|
+
const sshMatch = target.match(GITHUB_SSH_RE);
|
|
29
|
+
if (sshMatch) {
|
|
30
|
+
return { owner: sshMatch[1], repo: sshMatch[2], isSsh: true };
|
|
31
|
+
}
|
|
32
|
+
if (!isAbsolute(target) && !existsSync(target)) {
|
|
33
|
+
const slugMatch = target.match(GITHUB_SLUG_RE);
|
|
34
|
+
if (slugMatch) {
|
|
35
|
+
return { owner: slugMatch[1], repo: slugMatch[2], isSsh: false };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
export function resolveWikiRemote(projectRoot, remoteOrUrl) {
|
|
41
|
+
if (remoteOrUrl) {
|
|
42
|
+
if (remoteOrUrl.trim().startsWith('-')) {
|
|
43
|
+
throw new Error(`Invalid git remote or URL: ${remoteOrUrl}`);
|
|
44
|
+
}
|
|
45
|
+
assertNotUpstream(remoteOrUrl);
|
|
46
|
+
}
|
|
47
|
+
let resolved = remoteOrUrl;
|
|
48
|
+
// If omitted, default to origin
|
|
49
|
+
if (!resolved) {
|
|
50
|
+
try {
|
|
51
|
+
const originUrl = execFileSync('git', ['-C', projectRoot, 'remote', 'get-url', '--', 'origin'], {
|
|
52
|
+
encoding: 'utf-8',
|
|
53
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
54
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
55
|
+
}).trim();
|
|
56
|
+
assertNotUpstream(originUrl);
|
|
57
|
+
resolved = originUrl;
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
if (err.message.includes('Refusing to target upstream')) {
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
throw new Error(`No remote named 'origin' found in git repository. Specify --remote or --repo.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (!resolved.includes('/') &&
|
|
67
|
+
!resolved.includes(':') &&
|
|
68
|
+
!resolved.endsWith('.git')) {
|
|
69
|
+
// Single remote name token
|
|
70
|
+
try {
|
|
71
|
+
const namedUrl = execFileSync('git', ['-C', projectRoot, 'remote', 'get-url', '--', resolved], {
|
|
72
|
+
encoding: 'utf-8',
|
|
73
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
74
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
75
|
+
}).trim();
|
|
76
|
+
assertNotUpstream(namedUrl);
|
|
77
|
+
resolved = namedUrl;
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
if (err.message.includes('Refusing to target upstream')) {
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
// If remote get-url failed, fall through with the raw token
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
assertNotUpstream(resolved);
|
|
87
|
+
const gh = parseGitHubUrlOrSlug(resolved);
|
|
88
|
+
if (gh) {
|
|
89
|
+
const repoName = gh.repo;
|
|
90
|
+
const repoUrl = `https://github.com/${gh.owner}/${gh.repo}`;
|
|
91
|
+
const wikiRemoteUrl = gh.isSsh
|
|
92
|
+
? `git@github.com:${gh.owner}/${gh.repo}.wiki.git`
|
|
93
|
+
: `https://github.com/${gh.owner}/${gh.repo}.wiki.git`;
|
|
94
|
+
if (wikiRemoteUrl.trim().startsWith('-')) {
|
|
95
|
+
throw new Error(`Invalid wiki remote URL: ${wikiRemoteUrl}`);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
repoName,
|
|
99
|
+
repoUrl,
|
|
100
|
+
wikiRemoteUrl,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
// Treat as local filesystem path
|
|
104
|
+
let wikiRemoteUrl = resolved;
|
|
105
|
+
if (wikiRemoteUrl.endsWith('.wiki.git')) {
|
|
106
|
+
// already ends with .wiki.git
|
|
107
|
+
}
|
|
108
|
+
else if (wikiRemoteUrl.endsWith('.git')) {
|
|
109
|
+
wikiRemoteUrl = wikiRemoteUrl.slice(0, -4) + '.wiki.git';
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
wikiRemoteUrl = `${wikiRemoteUrl}.wiki.git`;
|
|
113
|
+
}
|
|
114
|
+
if (wikiRemoteUrl.trim().startsWith('-')) {
|
|
115
|
+
throw new Error(`Invalid wiki remote URL: ${wikiRemoteUrl}`);
|
|
116
|
+
}
|
|
117
|
+
const base = basename(resolved);
|
|
118
|
+
const repoName = base.replace(/\.wiki\.git$/, '').replace(/\.git$/, '');
|
|
119
|
+
return {
|
|
120
|
+
repoName,
|
|
121
|
+
repoUrl: undefined,
|
|
122
|
+
wikiRemoteUrl,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function resolveGitRef(projectRoot, explicitRef) {
|
|
126
|
+
if (explicitRef)
|
|
127
|
+
return explicitRef;
|
|
128
|
+
try {
|
|
129
|
+
const stdout = execFileSync('git', ['-C', projectRoot, 'rev-parse', 'HEAD'], {
|
|
130
|
+
encoding: 'utf-8',
|
|
131
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
132
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
133
|
+
}).trim();
|
|
134
|
+
if (stdout)
|
|
135
|
+
return stdout;
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// ignore
|
|
139
|
+
}
|
|
140
|
+
return 'HEAD';
|
|
141
|
+
}
|
|
142
|
+
export async function publishWiki(options) {
|
|
143
|
+
const projectRoot = options.projectRoot ?? dirname(options.latDir);
|
|
144
|
+
const remoteInfo = resolveWikiRemote(projectRoot, options.remote);
|
|
145
|
+
if (options.repoUrl) {
|
|
146
|
+
if (options.repoUrl.trim().startsWith('-')) {
|
|
147
|
+
throw new Error(`Invalid repo URL: ${options.repoUrl}`);
|
|
148
|
+
}
|
|
149
|
+
assertNotUpstream(options.repoUrl);
|
|
150
|
+
const gh = parseGitHubUrlOrSlug(options.repoUrl);
|
|
151
|
+
if (gh) {
|
|
152
|
+
remoteInfo.repoUrl = `https://github.com/${gh.owner}/${gh.repo}`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (remoteInfo.wikiRemoteUrl.trim().startsWith('-')) {
|
|
156
|
+
throw new Error(`Invalid wiki remote URL: ${remoteInfo.wikiRemoteUrl}`);
|
|
157
|
+
}
|
|
158
|
+
const ref = resolveGitRef(projectRoot, options.ref);
|
|
159
|
+
const shortSha = ref.slice(0, 7);
|
|
160
|
+
const rawCatalog = await buildWikiCatalog(options.latDir, projectRoot);
|
|
161
|
+
if (rawCatalog.docs.length === 0) {
|
|
162
|
+
throw new Error(`No Diataxis documents found in ${options.latDir} to publish.`);
|
|
163
|
+
}
|
|
164
|
+
const catalog = await transformWikiCatalog(rawCatalog, {
|
|
165
|
+
repoUrl: remoteInfo.repoUrl,
|
|
166
|
+
ref,
|
|
167
|
+
});
|
|
168
|
+
const cloneDir = await mkdtemp(join(tmpdir(), 'lat-wiki-clone-'));
|
|
169
|
+
try {
|
|
170
|
+
try {
|
|
171
|
+
await execFileAsync('git', ['clone', '--', remoteInfo.wikiRemoteUrl, cloneDir], {
|
|
172
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
const safeUrl = redactCredentials(remoteInfo.wikiRemoteUrl);
|
|
177
|
+
const safeMsg = redactCredentials(err.message);
|
|
178
|
+
throw new Error(`Failed to clone wiki repository (${safeUrl}). ` +
|
|
179
|
+
`GitHub requires enabling Wikis in repository settings and creating the initial page ` +
|
|
180
|
+
`in the repository's Wiki tab before the wiki repository can be cloned or pushed.\n` +
|
|
181
|
+
`${safeMsg}`);
|
|
182
|
+
}
|
|
183
|
+
const bundle = renderWikiBundle(catalog, { repoName: remoteInfo.repoName });
|
|
184
|
+
const { writtenFiles, removedFiles } = await writeWikiBundle(cloneDir, bundle, {
|
|
185
|
+
clean: true,
|
|
186
|
+
});
|
|
187
|
+
const statusOutput = (await execFileAsync('git', ['status', '--porcelain'], {
|
|
188
|
+
cwd: cloneDir,
|
|
189
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
190
|
+
})).stdout.trim();
|
|
191
|
+
if (!statusOutput) {
|
|
192
|
+
return {
|
|
193
|
+
wikiRemoteUrl: remoteInfo.wikiRemoteUrl,
|
|
194
|
+
repoUrl: remoteInfo.repoUrl,
|
|
195
|
+
ref,
|
|
196
|
+
pages: catalog.docs.length,
|
|
197
|
+
writtenFiles,
|
|
198
|
+
removedFiles,
|
|
199
|
+
changed: false,
|
|
200
|
+
pushed: false,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
await execFileAsync('git', ['add', '-A'], {
|
|
204
|
+
cwd: cloneDir,
|
|
205
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
206
|
+
});
|
|
207
|
+
const message = options.message ?? `Publish Diataxis documentation (${shortSha})`;
|
|
208
|
+
await execFileAsync('git', [
|
|
209
|
+
'-c',
|
|
210
|
+
'user.name=lat.md',
|
|
211
|
+
'-c',
|
|
212
|
+
'user.email=lat@users.noreply.github.com',
|
|
213
|
+
'-c',
|
|
214
|
+
'commit.gpgsign=false',
|
|
215
|
+
'commit',
|
|
216
|
+
'-m',
|
|
217
|
+
message,
|
|
218
|
+
], {
|
|
219
|
+
cwd: cloneDir,
|
|
220
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
221
|
+
});
|
|
222
|
+
const commitSha = (await execFileAsync('git', ['rev-parse', 'HEAD'], {
|
|
223
|
+
cwd: cloneDir,
|
|
224
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
225
|
+
})).stdout.trim();
|
|
226
|
+
if (options.dryRun) {
|
|
227
|
+
return {
|
|
228
|
+
wikiRemoteUrl: remoteInfo.wikiRemoteUrl,
|
|
229
|
+
repoUrl: remoteInfo.repoUrl,
|
|
230
|
+
ref,
|
|
231
|
+
pages: catalog.docs.length,
|
|
232
|
+
writtenFiles,
|
|
233
|
+
removedFiles,
|
|
234
|
+
changed: true,
|
|
235
|
+
pushed: false,
|
|
236
|
+
commitSha,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
await execFileAsync('git', ['push', 'origin', 'HEAD'], {
|
|
241
|
+
cwd: cloneDir,
|
|
242
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
catch (err) {
|
|
246
|
+
const safeUrl = redactCredentials(remoteInfo.wikiRemoteUrl);
|
|
247
|
+
const safeMsg = redactCredentials(err.message);
|
|
248
|
+
throw new Error(`Failed to push to wiki repository (${safeUrl}): ${safeMsg}`);
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
wikiRemoteUrl: remoteInfo.wikiRemoteUrl,
|
|
252
|
+
repoUrl: remoteInfo.repoUrl,
|
|
253
|
+
ref,
|
|
254
|
+
pages: catalog.docs.length,
|
|
255
|
+
writtenFiles,
|
|
256
|
+
removedFiles,
|
|
257
|
+
changed: true,
|
|
258
|
+
pushed: true,
|
|
259
|
+
commitSha,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
finally {
|
|
263
|
+
await rm(cloneDir, { recursive: true, force: true });
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { WikiCatalog } from './catalog.js';
|
|
2
|
+
export type WikiBundlePage = {
|
|
3
|
+
slug: string;
|
|
4
|
+
fileName: string;
|
|
5
|
+
content: string;
|
|
6
|
+
};
|
|
7
|
+
export type WikiBundle = {
|
|
8
|
+
home: string;
|
|
9
|
+
sidebar: string;
|
|
10
|
+
pages: WikiBundlePage[];
|
|
11
|
+
};
|
|
12
|
+
export declare function renderWikiBundle(catalog: WikiCatalog, options?: {
|
|
13
|
+
repoName?: string;
|
|
14
|
+
}): WikiBundle;
|
|
15
|
+
export declare function writeWikiBundle(outputDir: string, bundle: WikiBundle, options?: {
|
|
16
|
+
clean?: boolean;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
writtenFiles: string[];
|
|
19
|
+
removedFiles: string[];
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { lstat, mkdir, readdir, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, isAbsolute, join, resolve, sep } from 'node:path';
|
|
3
|
+
const MODE_ORDER = [
|
|
4
|
+
'tutorial',
|
|
5
|
+
'how-to',
|
|
6
|
+
'reference',
|
|
7
|
+
'explanation',
|
|
8
|
+
];
|
|
9
|
+
const MODE_HEADINGS = {
|
|
10
|
+
tutorial: { h2: '## Tutorials', h3: '### Tutorials' },
|
|
11
|
+
'how-to': { h2: '## How-To Guides', h3: '### How-To Guides' },
|
|
12
|
+
reference: { h2: '## Reference', h3: '### Reference' },
|
|
13
|
+
explanation: { h2: '## Explanation', h3: '### Explanation' },
|
|
14
|
+
};
|
|
15
|
+
function normalizeContent(content) {
|
|
16
|
+
return content.endsWith('\n') ? content : content + '\n';
|
|
17
|
+
}
|
|
18
|
+
export function renderWikiBundle(catalog, options) {
|
|
19
|
+
const rootTitle = catalog.rootTitle ?? options?.repoName ?? 'Documentation';
|
|
20
|
+
// Group docs by mode
|
|
21
|
+
const docsByMode = new Map();
|
|
22
|
+
for (const mode of MODE_ORDER) {
|
|
23
|
+
docsByMode.set(mode, []);
|
|
24
|
+
}
|
|
25
|
+
for (const doc of catalog.docs) {
|
|
26
|
+
const list = docsByMode.get(doc.mode);
|
|
27
|
+
if (list) {
|
|
28
|
+
list.push(doc);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Sort docs within each mode by slug
|
|
32
|
+
for (const list of docsByMode.values()) {
|
|
33
|
+
list.sort((a, b) => a.slug.localeCompare(b.slug));
|
|
34
|
+
}
|
|
35
|
+
// 1. Home.md
|
|
36
|
+
const homeParts = [];
|
|
37
|
+
homeParts.push(`# ${rootTitle}`);
|
|
38
|
+
if (catalog.rootOverview) {
|
|
39
|
+
homeParts.push(catalog.rootOverview);
|
|
40
|
+
}
|
|
41
|
+
for (const mode of MODE_ORDER) {
|
|
42
|
+
const docs = docsByMode.get(mode);
|
|
43
|
+
if (docs.length === 0)
|
|
44
|
+
continue;
|
|
45
|
+
homeParts.push(MODE_HEADINGS[mode].h2);
|
|
46
|
+
const lines = docs.map((doc) => {
|
|
47
|
+
const summary = doc.firstParagraph ? `: ${doc.firstParagraph}` : '';
|
|
48
|
+
return `- [${doc.title}](${doc.slug})${summary}`;
|
|
49
|
+
});
|
|
50
|
+
homeParts.push(lines.join('\n'));
|
|
51
|
+
}
|
|
52
|
+
const home = normalizeContent(homeParts.join('\n\n'));
|
|
53
|
+
// 2. _Sidebar.md
|
|
54
|
+
const sidebarParts = ['- [Home](Home)'];
|
|
55
|
+
for (const mode of MODE_ORDER) {
|
|
56
|
+
const docs = docsByMode.get(mode);
|
|
57
|
+
if (docs.length === 0)
|
|
58
|
+
continue;
|
|
59
|
+
const lines = docs.map((doc) => `- [${doc.title}](${doc.slug})`);
|
|
60
|
+
sidebarParts.push(`${MODE_HEADINGS[mode].h3}\n${lines.join('\n')}`);
|
|
61
|
+
}
|
|
62
|
+
const sidebar = normalizeContent(sidebarParts.join('\n\n'));
|
|
63
|
+
// 3. Pages ordered by slug
|
|
64
|
+
const sortedDocs = [...catalog.docs].sort((a, b) => a.slug.localeCompare(b.slug));
|
|
65
|
+
const pages = sortedDocs.map((doc) => ({
|
|
66
|
+
slug: doc.slug,
|
|
67
|
+
fileName: `${doc.slug}.md`,
|
|
68
|
+
content: normalizeContent(doc.body),
|
|
69
|
+
}));
|
|
70
|
+
return {
|
|
71
|
+
home,
|
|
72
|
+
sidebar,
|
|
73
|
+
pages,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async function verifyNoSymlinksInPath(targetPath) {
|
|
77
|
+
const absPath = resolve(targetPath);
|
|
78
|
+
const root = isAbsolute(absPath) ? resolve(sep) : '';
|
|
79
|
+
const parts = absPath.slice(root.length).split(sep);
|
|
80
|
+
let current = root;
|
|
81
|
+
for (const part of parts) {
|
|
82
|
+
if (!part)
|
|
83
|
+
continue;
|
|
84
|
+
current = join(current, part);
|
|
85
|
+
try {
|
|
86
|
+
const stat = await lstat(current);
|
|
87
|
+
if (stat.isSymbolicLink()) {
|
|
88
|
+
if (process.platform === 'darwin' &&
|
|
89
|
+
(current === '/var' || current === '/tmp' || current === '/etc')) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Refusing to write to symbolic link path: ${current}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
if (err.code === 'ENOENT') {
|
|
97
|
+
break; // remaining path does not exist yet
|
|
98
|
+
}
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export async function writeWikiBundle(outputDir, bundle, options) {
|
|
104
|
+
const absOutputDir = resolve(outputDir);
|
|
105
|
+
await verifyNoSymlinksInPath(absOutputDir);
|
|
106
|
+
await mkdir(absOutputDir, { recursive: true });
|
|
107
|
+
const filesToWrite = [
|
|
108
|
+
{ fileName: 'Home.md', content: bundle.home },
|
|
109
|
+
{ fileName: '_Sidebar.md', content: bundle.sidebar },
|
|
110
|
+
];
|
|
111
|
+
for (const page of bundle.pages) {
|
|
112
|
+
if (page.fileName.includes('/') ||
|
|
113
|
+
page.fileName.includes('\\') ||
|
|
114
|
+
page.fileName.includes('..') ||
|
|
115
|
+
page.slug.includes('/') ||
|
|
116
|
+
page.slug.includes('\\') ||
|
|
117
|
+
page.slug.includes('..')) {
|
|
118
|
+
throw new Error(`Invalid page slug or fileName: ${page.fileName}`);
|
|
119
|
+
}
|
|
120
|
+
filesToWrite.push({ fileName: page.fileName, content: page.content });
|
|
121
|
+
}
|
|
122
|
+
const writtenSet = new Set();
|
|
123
|
+
const writtenFiles = [];
|
|
124
|
+
for (const item of filesToWrite) {
|
|
125
|
+
const filePath = resolve(absOutputDir, item.fileName);
|
|
126
|
+
if (dirname(filePath) !== absOutputDir) {
|
|
127
|
+
throw new Error(`Path traversal attempted: ${item.fileName}`);
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const stat = await lstat(filePath);
|
|
131
|
+
if (stat.isSymbolicLink()) {
|
|
132
|
+
throw new Error(`Refusing to overwrite symbolic link: ${filePath}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
if (err.code !== 'ENOENT') {
|
|
137
|
+
throw err;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
await writeFile(filePath, item.content, 'utf-8');
|
|
141
|
+
writtenSet.add(item.fileName);
|
|
142
|
+
writtenFiles.push(item.fileName);
|
|
143
|
+
}
|
|
144
|
+
const removedFiles = [];
|
|
145
|
+
if (options?.clean) {
|
|
146
|
+
const writtenLower = new Set([...writtenSet].map((f) => f.toLowerCase()));
|
|
147
|
+
const entries = await readdir(absOutputDir);
|
|
148
|
+
for (const entry of entries) {
|
|
149
|
+
if (entry.toLowerCase().endsWith('.md') &&
|
|
150
|
+
!writtenLower.has(entry.toLowerCase())) {
|
|
151
|
+
const entryPath = join(absOutputDir, entry);
|
|
152
|
+
await rm(entryPath, { force: true });
|
|
153
|
+
removedFiles.push(entry);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
writtenFiles.sort();
|
|
158
|
+
removedFiles.sort();
|
|
159
|
+
return {
|
|
160
|
+
writtenFiles,
|
|
161
|
+
removedFiles,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WikiCatalog, WikiCatalogDoc } from './catalog.js';
|
|
2
|
+
export type WikiTransformOptions = {
|
|
3
|
+
repoUrl?: string;
|
|
4
|
+
ref?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function transformWikiDocument(doc: WikiCatalogDoc, catalog: WikiCatalog, options?: WikiTransformOptions): Promise<WikiCatalogDoc>;
|
|
7
|
+
export declare function transformWikiCatalog(catalog: WikiCatalog, options?: WikiTransformOptions): Promise<WikiCatalog>;
|