@plebeiantech/lat.md 0.12.3-fork.2 → 0.12.3-fork.20
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 +31 -2
- 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/comment-guard.d.ts +14 -0
- package/dist/src/cli/comment-guard.js +10 -33
- package/dist/src/cli/comment-reminder.d.ts +65 -6
- package/dist/src/cli/comment-reminder.js +164 -28
- package/dist/src/cli/fork-instructions.d.ts +20 -0
- package/dist/src/cli/fork-instructions.js +184 -0
- package/dist/src/cli/fork-scaffold.d.ts +106 -0
- package/dist/src/cli/fork-scaffold.js +490 -0
- package/dist/src/cli/graph.d.ts +1 -1
- package/dist/src/cli/hook.d.ts +26 -0
- package/dist/src/cli/hook.js +118 -46
- package/dist/src/cli/index.js +166 -64
- 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 +107 -50
- 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 +116 -100
- 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 +4 -0
- package/dist/src/cli/ui-build.js +13 -0
- package/dist/src/cli/ui.d.ts +1 -1
- package/dist/src/cli/ui.js +18 -2
- 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-cli.js +2 -0
- package/dist/src/fork/upstream-drift.d.ts +26 -0
- package/dist/src/fork/upstream-drift.js +185 -0
- package/dist/src/fork/upstream-guard-cli.d.ts +1 -0
- package/dist/src/fork/upstream-guard-cli.js +2 -0
- package/dist/src/fork/upstream-guard.d.ts +72 -0
- package/dist/src/fork/upstream-guard.js +445 -0
- package/dist/src/graph-export.d.ts +2 -0
- package/dist/src/graph-export.js +38 -19
- package/dist/src/knowledge/claude-memory.d.ts +1 -0
- package/dist/src/knowledge/claude-memory.js +33 -4
- 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 +197 -0
- package/dist/src/search/db.d.ts +28 -16
- package/dist/src/search/db.js +106 -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 -53
- 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 +17 -7
- package/dist/src/search/search.js +164 -14
- package/dist/src/search/types.d.ts +15 -0
- package/dist/src/search/types.js +1 -0
- package/dist/src/view/client/assets/GraphView-Dij8mAA_.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-88Wbt0M1.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-y0DlYa8E.js +1 -0
- package/dist/src/view/client/assets/arc-FlMu8dnO.js +1 -0
- package/dist/src/view/client/assets/architectureDiagram-5GKGNRK7-DA_uWZW1.js +36 -0
- package/dist/src/view/client/assets/blockDiagram-I7D4REHJ-BHQ5LU85.js +129 -0
- package/dist/src/view/client/assets/c4Diagram-7LVT6UL2-BRucKCt2.js +38 -0
- package/dist/src/view/client/assets/channel-BgDNA_Ay.js +1 -0
- package/dist/src/view/client/assets/chunk-2Q5K7J3B-BJPcFivt.js +1 -0
- package/dist/src/view/client/assets/chunk-5VM5RSS4-v2q99bGz.js +15 -0
- package/dist/src/view/client/assets/chunk-F27PBJKO-CcHOuJCs.js +1 -0
- package/dist/src/view/client/assets/chunk-IMKFNOWR-DNxYuJNq.js +231 -0
- package/dist/src/view/client/assets/chunk-JWPE2WC7-C0eHKvLW.js +1 -0
- package/dist/src/view/client/assets/chunk-POPQ4Y6H-57CWp2Ve.js +1 -0
- package/dist/src/view/client/assets/chunk-SVP7TREG-BqcoxIJw.js +88 -0
- package/dist/src/view/client/assets/chunk-TICWLB2K-DRUJR5zH.js +206 -0
- package/dist/src/view/client/assets/chunk-XXDRQBXY-Dez0oRoM.js +1 -0
- package/dist/src/view/client/assets/classDiagram-ZZMXUADV-CFZ_Sgh5.js +1 -0
- package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-CFZ_Sgh5.js +1 -0
- package/dist/src/view/client/assets/cose-bilkent-JH36ORCC-BHtud6Hg.js +1 -0
- package/dist/src/view/client/assets/cynefin-OW5HDTMX-BjBW8VGk.js +166 -0
- package/dist/src/view/client/assets/cynefinDiagram-5FMLGOSQ-DwGuD7oF.js +62 -0
- package/dist/src/view/client/assets/cytoscape.esm-DzSz-X2X.js +321 -0
- package/dist/src/view/client/assets/dagre-GXQ25YYZ-C5zSlGK9.js +4 -0
- package/dist/src/view/client/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/src/view/client/assets/diagram-S7CK7UJ4-C_NhA3bj.js +30 -0
- package/dist/src/view/client/assets/diagram-UQ7AKVKN-az7QPYNb.js +41 -0
- package/dist/src/view/client/assets/diagram-VSXAHHWV-BRvDuM8_.js +3 -0
- package/dist/src/view/client/assets/diagram-VX7I27RA-BWLgF6S-.js +24 -0
- package/dist/src/view/client/assets/diagram-Z3DM3KII-DV3d6mL5.js +24 -0
- package/dist/src/view/client/assets/ebnfDiagram-PWID7BFC-yUXrEAvK.js +1 -0
- package/dist/src/view/client/assets/erDiagram-RLTQ6QDP-D35FN1Pt.js +99 -0
- package/dist/src/view/client/assets/flowDiagram-HODETNUW-BciZqsjT.js +168 -0
- package/dist/src/view/client/assets/ganttDiagram-EL5Y4UJY-BysPGgXS.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-C3DdJ5xG.js +106 -0
- package/dist/src/view/client/assets/index-BnENo9bV.js +1 -0
- package/dist/src/view/client/assets/index-CJokoRSp.js +13 -0
- package/dist/src/view/client/assets/index-DG0Ez15D.css +1 -0
- package/dist/src/view/client/assets/infoDiagram-27XIBGKW-D3HZrDRb.js +2 -0
- package/dist/src/view/client/assets/init-Gi6I4Gst.js +1 -0
- package/dist/src/view/client/assets/ishikawaDiagram-5VMMS53U-BXyVIXTU.js +70 -0
- package/dist/src/view/client/assets/journeyDiagram-3NMN7TZE-D4-1NxVU.js +139 -0
- package/dist/src/view/client/assets/kanban-definition-UXKFOSKX-4Gu_5yBA.js +89 -0
- package/dist/src/view/client/assets/katex-HP8lGamR.js +257 -0
- package/dist/src/view/client/assets/layout-Jf1K3TMM.js +1 -0
- package/dist/src/view/client/assets/linear-DWfwzUT_.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-DMx_DAl8.js +310 -0
- package/dist/src/view/client/assets/mindmap-definition-YA3MSWOX-8pxY_RWi.js +96 -0
- package/dist/src/view/client/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/src/view/client/assets/pegDiagram-XKGWAZYB-DNAw_O5t.js +1 -0
- package/dist/src/view/client/assets/pieDiagram-E7YTZNPT-uuvRCDkC.js +39 -0
- package/dist/src/view/client/assets/quadrantDiagram-AXDQQJYC-BER2O4Aq.js +7 -0
- package/dist/src/view/client/assets/railroadDiagram-O6MQD6OU-CxEsJ_0n.js +1 -0
- package/dist/src/view/client/assets/requirementDiagram-BXWQKSXE-yS9rspca.js +84 -0
- package/dist/src/view/client/assets/sankeyDiagram-P5KCCOFB-Bqt70a2j.js +40 -0
- package/dist/src/view/client/assets/sequenceDiagram-WJ2MYXX4-BvOOEJNr.js +162 -0
- package/dist/src/view/client/assets/sizeCapture-INFHLROL-CvO_Pjjo.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-D77RDMKH-KLmVOZkq.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-KCS8Mdzu.js +1 -0
- package/dist/src/view/client/assets/swimlanes-42K2YHIH-DC1r4_sq.js +1 -0
- package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-B2TcAwis.js +8 -0
- package/dist/src/view/client/assets/three.module-PDSP0dbZ.js +4108 -0
- package/dist/src/view/client/assets/timeline-definition-24CTP7MA-ChXLOuBL.js +120 -0
- package/dist/src/view/client/assets/vennDiagram-4TSXK5OY-D9_h25-Y.js +34 -0
- package/dist/src/view/client/assets/wardleyDiagram-VM6X3IG4-CsQJGGW0.js +78 -0
- package/dist/src/view/client/assets/xychartDiagram-S5SC5T6Z-DGMuPMlm.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 +126 -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 +205 -1
- package/dist/src/view/git.js +1 -1
- package/dist/src/view/graph.d.ts +7 -0
- package/dist/src/view/graph.js +267 -0
- package/dist/src/view/highlight.d.ts +10 -2
- package/dist/src/view/highlight.js +4547 -1363
- package/dist/src/view/markdown.d.ts +8 -3
- package/dist/src/view/markdown.js +308 -41
- 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 +95 -6
- package/dist/src/view/protocol.js +1 -1
- package/dist/src/view/publication.d.ts +2 -0
- package/dist/src/view/publication.js +78 -0
- package/dist/src/view/references.d.ts +13 -26
- package/dist/src/view/references.js +150 -119
- package/dist/src/view/repository.d.ts +18 -5
- package/dist/src/view/repository.js +269 -27
- 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 -33
- 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 +94 -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 +14 -2
- package/dist/src/view/server.js +254 -51
- package/dist/src/view/source-target.d.ts +10 -0
- package/dist/src/view/source-target.js +43 -0
- package/dist/src/view/static-build.d.ts +32 -0
- package/dist/src/view/static-build.js +741 -0
- package/dist/src/view/static-protocol.d.ts +47 -0
- package/dist/src/view/static-protocol.js +15 -0
- package/dist/src/view/store.d.ts +26 -3
- package/dist/src/view/store.js +325 -44
- package/dist/src/view/table-of-contents.d.ts +9 -0
- package/dist/src/view/table-of-contents.js +83 -0
- package/dist/src/view/vercel-build.d.ts +24 -0
- package/dist/src/view/vercel-build.js +140 -0
- package/dist/src/view/vercel-server-build.d.ts +10 -0
- package/dist/src/view/vercel-server-build.js +61 -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 +72 -25
- 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 +118 -0
- package/plugins/lat-md/skills/lat-md/SKILL.md +178 -0
- package/plugins/lat-md/skills/lat-md-conventions/SKILL.md +182 -0
- package/templates/AGENTS.md +19 -18
- package/templates/cursor-rules.md +14 -5
- package/templates/fork/conventions.md +173 -0
- package/templates/opencode-plugin.ts +9 -9
- package/templates/pi-extension.ts +11 -11
- package/templates/skill/SKILL.md +28 -17
- 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 -6
- package/dist/src/cli/check-mode.js +0 -303
- 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 -777
- 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 -277
- 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 -108
- package/dist/src/lattice.js +0 -816
- 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 -24
- package/dist/src/untrusted.js +0 -97
- package/dist/src/view/client/assets/index-B0n0u03y.css +0 -1
- package/dist/src/view/client/assets/index-xm2_px4q.js +0 -23
- package/dist/src/walk.d.ts +0 -18
- package/dist/src/walk.js +0 -27
- /package/dist/src/{extensions/wiki-link/types.js → fork/upstream-drift-cli.d.ts} +0 -0
package/dist/src/cli/refs.js
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import { extname, join, relative } from 'node:path';
|
|
4
|
-
import { listLatticeFiles, loadAllSections, findSections, extractRefs, flattenSections, buildFileIndex, buildSectionSlugIndex, resolveRef, } from '../lattice.js';
|
|
5
|
-
import { formatResultList } from '../format.js';
|
|
6
|
-
import { scanCodeRefs } from '../code-refs.js';
|
|
7
|
-
/** Extensions recognized as source code for ref queries. */
|
|
8
|
-
const SOURCE_EXTS = new Set([
|
|
9
|
-
'.ts',
|
|
10
|
-
'.tsx',
|
|
11
|
-
'.js',
|
|
12
|
-
'.jsx',
|
|
13
|
-
'.py',
|
|
14
|
-
'.rs',
|
|
15
|
-
'.go',
|
|
16
|
-
'.c',
|
|
17
|
-
'.h',
|
|
18
|
-
]);
|
|
19
|
-
/**
|
|
20
|
-
* Check if a query looks like a source file path (has a recognized extension
|
|
21
|
-
* and the file exists on disk).
|
|
22
|
-
*/
|
|
23
|
-
function isSourceQuery(query, projectRoot) {
|
|
24
|
-
const hashIdx = query.indexOf('#');
|
|
25
|
-
const filePart = hashIdx === -1 ? query : query.slice(0, hashIdx);
|
|
26
|
-
const symbolPart = hashIdx === -1 ? '' : query.slice(hashIdx + 1);
|
|
27
|
-
const ext = extname(filePart);
|
|
28
|
-
if (!SOURCE_EXTS.has(ext))
|
|
29
|
-
return null;
|
|
30
|
-
if (!existsSync(join(projectRoot, filePart)))
|
|
31
|
-
return null;
|
|
32
|
-
return { filePart, symbolPart };
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Find references to a source file or symbol across lat.md and code files.
|
|
36
|
-
* For file-level queries (no #symbol), matches all wiki links targeting
|
|
37
|
-
* that file or any symbol in it.
|
|
38
|
-
*/
|
|
39
|
-
async function findSourceRefs(latDir, projectRoot, query, scope) {
|
|
40
|
-
const hashIdx = query.indexOf('#');
|
|
41
|
-
const filePart = hashIdx === -1 ? query : query.slice(0, hashIdx);
|
|
42
|
-
const isFileLevel = hashIdx === -1;
|
|
43
|
-
const queryLower = query.toLowerCase();
|
|
44
|
-
const fileLower = filePart.toLowerCase();
|
|
45
|
-
// Build a synthetic Section for the target
|
|
46
|
-
const target = {
|
|
47
|
-
id: query,
|
|
48
|
-
heading: hashIdx === -1 ? filePart : query.slice(hashIdx + 1),
|
|
49
|
-
depth: 0,
|
|
50
|
-
file: filePart,
|
|
51
|
-
filePath: filePart,
|
|
52
|
-
children: [],
|
|
53
|
-
startLine: 0,
|
|
54
|
-
endLine: 0,
|
|
55
|
-
firstParagraph: '',
|
|
56
|
-
};
|
|
57
|
-
// Try to get real line info from the source parser
|
|
58
|
-
try {
|
|
59
|
-
const { resolveSourceSymbol } = await import('../source-parser.js');
|
|
60
|
-
if (hashIdx !== -1) {
|
|
61
|
-
const symbolPart = query.slice(hashIdx + 1);
|
|
62
|
-
const { found, symbols } = await resolveSourceSymbol(filePart, symbolPart, projectRoot);
|
|
63
|
-
if (found) {
|
|
64
|
-
const parts = symbolPart.split('#');
|
|
65
|
-
const sym = symbols.find((s) => parts.length === 1
|
|
66
|
-
? s.name === parts[0] && !s.parent
|
|
67
|
-
: s.name === parts[1] && s.parent === parts[0]);
|
|
68
|
-
if (sym) {
|
|
69
|
-
target.startLine = sym.startLine;
|
|
70
|
-
target.endLine = sym.endLine;
|
|
71
|
-
target.firstParagraph = sym.signature;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
// source parser unavailable — proceed without line info
|
|
78
|
-
}
|
|
79
|
-
const allSections = await loadAllSections(latDir);
|
|
80
|
-
const flat = flattenSections(allSections);
|
|
81
|
-
const mdRefs = [];
|
|
82
|
-
const codeRefs = [];
|
|
83
|
-
if (scope === 'md' || scope === 'md+code') {
|
|
84
|
-
const files = await listLatticeFiles(latDir);
|
|
85
|
-
const matchingFromSections = new Set();
|
|
86
|
-
for (const file of files) {
|
|
87
|
-
const content = await readFile(file, 'utf-8');
|
|
88
|
-
const fileRefs = extractRefs(file, content, projectRoot);
|
|
89
|
-
for (const ref of fileRefs) {
|
|
90
|
-
const targetLower = ref.target.toLowerCase();
|
|
91
|
-
const matches = isFileLevel
|
|
92
|
-
? targetLower === fileLower || targetLower.startsWith(fileLower + '#')
|
|
93
|
-
: targetLower === queryLower;
|
|
94
|
-
if (matches) {
|
|
95
|
-
matchingFromSections.add(ref.fromSection.toLowerCase());
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (matchingFromSections.size > 0) {
|
|
100
|
-
const referrers = flat.filter((s) => matchingFromSections.has(s.id.toLowerCase()));
|
|
101
|
-
for (const s of referrers) {
|
|
102
|
-
mdRefs.push({ section: s, reason: 'wiki link' });
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (scope === 'code' || scope === 'md+code') {
|
|
107
|
-
const { refs: scannedRefs } = await scanCodeRefs(projectRoot);
|
|
108
|
-
for (const ref of scannedRefs) {
|
|
109
|
-
const targetLower = ref.target.toLowerCase();
|
|
110
|
-
const matches = isFileLevel
|
|
111
|
-
? targetLower === fileLower || targetLower.startsWith(fileLower + '#')
|
|
112
|
-
: targetLower === queryLower;
|
|
113
|
-
if (matches) {
|
|
114
|
-
const displayPath = relative(process.cwd(), join(projectRoot, ref.file));
|
|
115
|
-
codeRefs.push(`${displayPath}:${ref.line}`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return { kind: 'found', target, mdRefs, codeRefs };
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Find all sections and code locations that reference a given section or
|
|
123
|
-
* source file. Accepts section ids (full-path, short-form) and source file
|
|
124
|
-
* paths (e.g. src/app.rs#foo). Source file queries match wiki links directly
|
|
125
|
-
* without section resolution.
|
|
126
|
-
*/
|
|
127
|
-
export async function findRefs(ctx, query, scope) {
|
|
128
|
-
query = query.replace(/^\[\[|\]\]$/g, '');
|
|
129
|
-
// Source file queries bypass section resolution
|
|
130
|
-
if (isSourceQuery(query, ctx.projectRoot)) {
|
|
131
|
-
return findSourceRefs(ctx.latDir, ctx.projectRoot, query, scope);
|
|
132
|
-
}
|
|
133
|
-
const allSections = await loadAllSections(ctx.latDir);
|
|
134
|
-
const flat = flattenSections(allSections);
|
|
135
|
-
const sectionIds = new Set(flat.map((s) => s.id.toLowerCase()));
|
|
136
|
-
const fileIndex = buildFileIndex(allSections);
|
|
137
|
-
const slugIndex = buildSectionSlugIndex(allSections);
|
|
138
|
-
const { resolved } = resolveRef(query, sectionIds, fileIndex, slugIndex);
|
|
139
|
-
const q = resolved.toLowerCase();
|
|
140
|
-
let exactMatch = flat.find((s) => s.id.toLowerCase() === q);
|
|
141
|
-
// If resolveRef didn't land on an exact id, use findSections as fallback
|
|
142
|
-
const matches = !exactMatch ? findSections(allSections, query) : [];
|
|
143
|
-
if (!exactMatch && matches.length >= 1) {
|
|
144
|
-
const top = matches[0];
|
|
145
|
-
const isConfident = top.reason === 'exact match' ||
|
|
146
|
-
top.reason.startsWith('file stem expanded') ||
|
|
147
|
-
top.reason === 'section name match';
|
|
148
|
-
if (isConfident) {
|
|
149
|
-
exactMatch = top.section;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (!exactMatch) {
|
|
153
|
-
const suggestions = matches.length > 0 ? matches : findSections(allSections, query);
|
|
154
|
-
return { kind: 'no-match', suggestions };
|
|
155
|
-
}
|
|
156
|
-
const targetId = exactMatch.id.toLowerCase();
|
|
157
|
-
const mdRefs = [];
|
|
158
|
-
const codeRefs = [];
|
|
159
|
-
if (scope === 'md' || scope === 'md+code') {
|
|
160
|
-
const files = await listLatticeFiles(ctx.latDir);
|
|
161
|
-
const matchingFromSections = new Set();
|
|
162
|
-
for (const file of files) {
|
|
163
|
-
const content = await readFile(file, 'utf-8');
|
|
164
|
-
const fileRefs = extractRefs(file, content, ctx.projectRoot);
|
|
165
|
-
for (const ref of fileRefs) {
|
|
166
|
-
const { resolved: refResolved } = resolveRef(ref.target, sectionIds, fileIndex, slugIndex);
|
|
167
|
-
if (refResolved.toLowerCase() === targetId) {
|
|
168
|
-
matchingFromSections.add(ref.fromSection.toLowerCase());
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (matchingFromSections.size > 0) {
|
|
173
|
-
const referrers = flat.filter((s) => matchingFromSections.has(s.id.toLowerCase()));
|
|
174
|
-
for (const s of referrers) {
|
|
175
|
-
mdRefs.push({ section: s, reason: 'wiki link' });
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if (scope === 'code' || scope === 'md+code') {
|
|
180
|
-
const { refs: scannedRefs } = await scanCodeRefs(ctx.projectRoot);
|
|
181
|
-
for (const ref of scannedRefs) {
|
|
182
|
-
const { resolved: codeResolved } = resolveRef(ref.target, sectionIds, fileIndex, slugIndex);
|
|
183
|
-
if (codeResolved.toLowerCase() === targetId) {
|
|
184
|
-
const displayPath = relative(process.cwd(), join(ctx.projectRoot, ref.file));
|
|
185
|
-
codeRefs.push(`${displayPath}:${ref.line}`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return { kind: 'found', target: exactMatch, mdRefs, codeRefs };
|
|
190
|
-
}
|
|
191
|
-
export async function refsCommand(ctx, query, scope) {
|
|
192
|
-
const result = await findRefs(ctx, query, scope);
|
|
193
|
-
if (result.kind === 'no-match') {
|
|
194
|
-
const s = ctx.styler;
|
|
195
|
-
if (result.suggestions.length > 0) {
|
|
196
|
-
const suggestions = result.suggestions
|
|
197
|
-
.map((m) => ` ${s.dim('*')} ${s.white(m.section.id)} ${s.dim(`(${m.reason})`)}`)
|
|
198
|
-
.join('\n');
|
|
199
|
-
return {
|
|
200
|
-
output: s.red(`No section "${query}" found.`) +
|
|
201
|
-
' Did you mean:\n' +
|
|
202
|
-
suggestions,
|
|
203
|
-
isError: true,
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
output: s.red(`No section matching "${query}"`),
|
|
208
|
-
isError: true,
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
const { target, mdRefs, codeRefs } = result;
|
|
212
|
-
if (mdRefs.length === 0 && codeRefs.length === 0) {
|
|
213
|
-
return {
|
|
214
|
-
output: ctx.styler.yellow(`No references to "${target.id}" found`),
|
|
215
|
-
isError: true,
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
const s = ctx.styler;
|
|
219
|
-
const parts = [];
|
|
220
|
-
if (mdRefs.length > 0) {
|
|
221
|
-
parts.push(formatResultList(ctx, `References to "${target.id}":`, mdRefs));
|
|
222
|
-
}
|
|
223
|
-
if (codeRefs.length > 0) {
|
|
224
|
-
parts.push('## Code references:' +
|
|
225
|
-
'\n\n' +
|
|
226
|
-
codeRefs.map((l) => `${s.dim('*')} ${l}`).join('\n'));
|
|
227
|
-
}
|
|
228
|
-
return { output: parts.join('\n') };
|
|
229
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type Section, type SectionMatch } from '../lattice.js';
|
|
2
|
-
import type { CmdContext, CmdResult } from '../context.js';
|
|
3
|
-
import { type ProvenanceNote } from './check-status.js';
|
|
4
|
-
export type CodeBackRef = {
|
|
5
|
-
file: string;
|
|
6
|
-
line: number;
|
|
7
|
-
snippet: string;
|
|
8
|
-
};
|
|
9
|
-
export type SourceRef = {
|
|
10
|
-
target: string;
|
|
11
|
-
file: string;
|
|
12
|
-
line: number;
|
|
13
|
-
endLine: number;
|
|
14
|
-
snippet: string;
|
|
15
|
-
};
|
|
16
|
-
export type SectionFound = {
|
|
17
|
-
kind: 'found';
|
|
18
|
-
section: Section;
|
|
19
|
-
content: string;
|
|
20
|
-
/** Provenance of the document holding this section, or null if unmarked. */
|
|
21
|
-
status: ProvenanceNote | null;
|
|
22
|
-
outgoingRefs: {
|
|
23
|
-
target: string;
|
|
24
|
-
resolved: Section;
|
|
25
|
-
}[];
|
|
26
|
-
outgoingSourceRefs: SourceRef[];
|
|
27
|
-
incomingRefs: SectionMatch[];
|
|
28
|
-
codeRefs: CodeBackRef[];
|
|
29
|
-
};
|
|
30
|
-
export type SectionResult = SectionFound | {
|
|
31
|
-
kind: 'no-match';
|
|
32
|
-
suggestions: SectionMatch[];
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Look up a section by id, return its content, outgoing wiki link targets,
|
|
36
|
-
* and incoming references from other sections.
|
|
37
|
-
*/
|
|
38
|
-
export declare function getSection(ctx: CmdContext, query: string): Promise<SectionResult>;
|
|
39
|
-
/**
|
|
40
|
-
* Format a successful section result with styling.
|
|
41
|
-
*/
|
|
42
|
-
export declare function formatSectionOutput(ctx: CmdContext, result: SectionFound): string;
|
|
43
|
-
export declare function sectionCommand(ctx: CmdContext, query: string): Promise<CmdResult>;
|
package/dist/src/cli/section.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { extname, join, relative } from 'node:path';
|
|
3
|
-
import { loadAllSections, findSections, flattenSections, extractRefs, buildFileIndex, buildSectionSlugIndex, resolveRef, listLatticeFiles, } from '../lattice.js';
|
|
4
|
-
import { scanCodeRefs } from '../code-refs.js';
|
|
5
|
-
import { SOURCE_EXTENSIONS, resolveSourceSymbol } from '../source-parser.js';
|
|
6
|
-
import { formatSectionId, formatNavHints } from '../format.js';
|
|
7
|
-
import { provenanceNote, formatProvenanceNote, } from './check-status.js';
|
|
8
|
-
/**
|
|
9
|
-
* Look up a section by id, return its content, outgoing wiki link targets,
|
|
10
|
-
* and incoming references from other sections.
|
|
11
|
-
*/
|
|
12
|
-
export async function getSection(ctx, query) {
|
|
13
|
-
query = query.replace(/^\[\[|\]\]$/g, '');
|
|
14
|
-
const allSections = await loadAllSections(ctx.latDir);
|
|
15
|
-
const matches = findSections(allSections, query);
|
|
16
|
-
if (matches.length === 0) {
|
|
17
|
-
return { kind: 'no-match', suggestions: [] };
|
|
18
|
-
}
|
|
19
|
-
// Accept the top match if confident
|
|
20
|
-
const top = matches[0];
|
|
21
|
-
const isConfident = top.reason === 'exact match' ||
|
|
22
|
-
top.reason.startsWith('file stem expanded') ||
|
|
23
|
-
top.reason === 'section name match';
|
|
24
|
-
if (!isConfident) {
|
|
25
|
-
return { kind: 'no-match', suggestions: matches };
|
|
26
|
-
}
|
|
27
|
-
const section = top.section;
|
|
28
|
-
// Read raw content between startLine and the end of the last descendant
|
|
29
|
-
const absPath = join(ctx.projectRoot, section.filePath);
|
|
30
|
-
const fileContent = await readFile(absPath, 'utf-8');
|
|
31
|
-
const lines = fileContent.split('\n');
|
|
32
|
-
const end = fullEndLine(section);
|
|
33
|
-
const content = lines.slice(section.startLine - 1, end).join('\n');
|
|
34
|
-
// Find outgoing wiki link targets within this section's content
|
|
35
|
-
const flat = flattenSections(allSections);
|
|
36
|
-
const sectionIds = new Set(flat.map((s) => s.id.toLowerCase()));
|
|
37
|
-
const fileIndex = buildFileIndex(allSections);
|
|
38
|
-
const slugIndex = buildSectionSlugIndex(allSections);
|
|
39
|
-
const sectionRefs = extractRefs(absPath, fileContent, ctx.projectRoot);
|
|
40
|
-
const sectionId = section.id.toLowerCase();
|
|
41
|
-
const outgoingRefs = [];
|
|
42
|
-
const outgoingSourceRefs = [];
|
|
43
|
-
const seen = new Set();
|
|
44
|
-
for (const ref of sectionRefs) {
|
|
45
|
-
if (ref.fromSection.toLowerCase() !== sectionId)
|
|
46
|
-
continue;
|
|
47
|
-
// Detect source code references by file extension
|
|
48
|
-
const hashIdx = ref.target.indexOf('#');
|
|
49
|
-
const filePart = hashIdx === -1 ? ref.target : ref.target.slice(0, hashIdx);
|
|
50
|
-
const ext = extname(filePart);
|
|
51
|
-
if (SOURCE_EXTENSIONS.has(ext)) {
|
|
52
|
-
const targetLower = ref.target.toLowerCase();
|
|
53
|
-
if (!seen.has(targetLower)) {
|
|
54
|
-
seen.add(targetLower);
|
|
55
|
-
const symbolPart = hashIdx === -1 ? '' : ref.target.slice(hashIdx + 1);
|
|
56
|
-
let line = 0;
|
|
57
|
-
let endLine = 0;
|
|
58
|
-
let snippet = '';
|
|
59
|
-
if (symbolPart) {
|
|
60
|
-
const { found, symbols } = await resolveSourceSymbol(filePart, symbolPart, ctx.projectRoot);
|
|
61
|
-
if (found) {
|
|
62
|
-
const parts = symbolPart.split('#');
|
|
63
|
-
const sym = symbols.find((s) => parts.length === 1
|
|
64
|
-
? s.name === parts[0] && !s.parent
|
|
65
|
-
: s.name === parts[1] && s.parent === parts[0]);
|
|
66
|
-
if (sym) {
|
|
67
|
-
line = sym.startLine;
|
|
68
|
-
endLine = sym.endLine;
|
|
69
|
-
try {
|
|
70
|
-
const src = await readFile(join(ctx.projectRoot, filePart), 'utf-8');
|
|
71
|
-
const srcLines = src.split('\n');
|
|
72
|
-
const start = sym.startLine - 1;
|
|
73
|
-
const end = Math.min(srcLines.length, start + 5);
|
|
74
|
-
snippet = srcLines.slice(start, end).join('\n');
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
// file unreadable
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
outgoingSourceRefs.push({
|
|
83
|
-
target: ref.target,
|
|
84
|
-
file: filePart,
|
|
85
|
-
line,
|
|
86
|
-
endLine,
|
|
87
|
-
snippet,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
const { resolved } = resolveRef(ref.target, sectionIds, fileIndex, slugIndex);
|
|
93
|
-
const resolvedLower = resolved.toLowerCase();
|
|
94
|
-
if (seen.has(resolvedLower))
|
|
95
|
-
continue;
|
|
96
|
-
seen.add(resolvedLower);
|
|
97
|
-
const targetSection = flat.find((s) => s.id.toLowerCase() === resolvedLower);
|
|
98
|
-
if (targetSection) {
|
|
99
|
-
outgoingRefs.push({ target: ref.target, resolved: targetSection });
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
// Find incoming references: other sections that link to this one
|
|
103
|
-
const incomingRefs = [];
|
|
104
|
-
const files = await listLatticeFiles(ctx.latDir);
|
|
105
|
-
const incomingSections = new Set();
|
|
106
|
-
for (const file of files) {
|
|
107
|
-
const fc = await readFile(file, 'utf-8');
|
|
108
|
-
const fileRefs = extractRefs(file, fc, ctx.projectRoot);
|
|
109
|
-
for (const ref of fileRefs) {
|
|
110
|
-
const { resolved } = resolveRef(ref.target, sectionIds, fileIndex, slugIndex);
|
|
111
|
-
if (resolved.toLowerCase() === sectionId &&
|
|
112
|
-
ref.fromSection.toLowerCase() !== sectionId) {
|
|
113
|
-
if (!incomingSections.has(ref.fromSection.toLowerCase())) {
|
|
114
|
-
incomingSections.add(ref.fromSection.toLowerCase());
|
|
115
|
-
const fromSection = flat.find((s) => s.id.toLowerCase() === ref.fromSection.toLowerCase());
|
|
116
|
-
if (fromSection) {
|
|
117
|
-
incomingRefs.push({ section: fromSection, reason: 'wiki link' });
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// Find code back-references: @lat: comments pointing to this section
|
|
124
|
-
const codeRefs = [];
|
|
125
|
-
const { refs: scannedRefs } = await scanCodeRefs(ctx.projectRoot);
|
|
126
|
-
for (const ref of scannedRefs) {
|
|
127
|
-
const { resolved: codeResolved } = resolveRef(ref.target, sectionIds, fileIndex, slugIndex);
|
|
128
|
-
if (codeResolved.toLowerCase() === sectionId) {
|
|
129
|
-
const absFile = join(ctx.projectRoot, ref.file);
|
|
130
|
-
let snippet = '';
|
|
131
|
-
try {
|
|
132
|
-
const src = await readFile(absFile, 'utf-8');
|
|
133
|
-
const srcLines = src.split('\n');
|
|
134
|
-
const start = Math.max(0, ref.line - 1 - 2);
|
|
135
|
-
const end = Math.min(srcLines.length, ref.line - 1 + 3);
|
|
136
|
-
snippet = srcLines.slice(start, end).join('\n');
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
// file unreadable — skip snippet
|
|
140
|
-
}
|
|
141
|
-
codeRefs.push({ file: ref.file, line: ref.line, snippet });
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return {
|
|
145
|
-
kind: 'found',
|
|
146
|
-
section,
|
|
147
|
-
content,
|
|
148
|
-
status: provenanceNote(fileContent),
|
|
149
|
-
outgoingRefs,
|
|
150
|
-
outgoingSourceRefs,
|
|
151
|
-
incomingRefs,
|
|
152
|
-
codeRefs,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function fullEndLine(section) {
|
|
156
|
-
if (section.children.length === 0)
|
|
157
|
-
return section.endLine;
|
|
158
|
-
return fullEndLine(section.children[section.children.length - 1]);
|
|
159
|
-
}
|
|
160
|
-
function truncate(s, max) {
|
|
161
|
-
return s.length > max ? s.slice(0, max) + '...' : s;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Format a successful section result with styling.
|
|
165
|
-
*/
|
|
166
|
-
export function formatSectionOutput(ctx, result) {
|
|
167
|
-
const s = ctx.styler;
|
|
168
|
-
const { section, content, status, outgoingRefs, outgoingSourceRefs, incomingRefs, codeRefs, } = result;
|
|
169
|
-
const relPath = relative(process.cwd(), join(ctx.projectRoot, section.filePath));
|
|
170
|
-
const loc = `${s.cyan(relPath)}${s.dim(`:${section.startLine}-${section.endLine}`)}`;
|
|
171
|
-
const quoted = content
|
|
172
|
-
.split('\n')
|
|
173
|
-
.map((line) => (line ? `> ${line}` : '>'))
|
|
174
|
-
.join('\n');
|
|
175
|
-
const parts = [
|
|
176
|
-
`${s.bold('[[' + formatSectionId(section.id, s) + ']]')} (${loc})`,
|
|
177
|
-
];
|
|
178
|
-
// Above the text, not below it: a reader who acts on the first line of a
|
|
179
|
-
// quoted section has already acted before a trailing caveat reaches them.
|
|
180
|
-
if (status)
|
|
181
|
-
parts.push(formatProvenanceNote(status, s));
|
|
182
|
-
parts.push('', quoted);
|
|
183
|
-
if (outgoingRefs.length > 0 || outgoingSourceRefs.length > 0) {
|
|
184
|
-
parts.push('', '## This section references:', '');
|
|
185
|
-
for (const ref of outgoingRefs) {
|
|
186
|
-
const body = ref.resolved.firstParagraph
|
|
187
|
-
? ` ${s.dim('—')} ${truncate(ref.resolved.firstParagraph, 120)}`
|
|
188
|
-
: '';
|
|
189
|
-
parts.push(`${s.dim('*')} [[${formatSectionId(ref.resolved.id, s)}]]${body}`);
|
|
190
|
-
}
|
|
191
|
-
for (const ref of outgoingSourceRefs) {
|
|
192
|
-
const loc = ref.line
|
|
193
|
-
? ref.endLine && ref.endLine !== ref.line
|
|
194
|
-
? `${s.dim(` (${ref.file}:${ref.line}-${ref.endLine})`)}`
|
|
195
|
-
: `${s.dim(` (${ref.file}:${ref.line})`)}`
|
|
196
|
-
: `${s.dim(` (${ref.file})`)}`;
|
|
197
|
-
parts.push(`${s.dim('*')} [[${s.cyan(ref.target)}]]${loc}`);
|
|
198
|
-
if (ref.snippet) {
|
|
199
|
-
const snippetLines = ref.snippet.split('\n');
|
|
200
|
-
for (const line of snippetLines) {
|
|
201
|
-
parts.push(` ${s.dim('|')} ${line}`);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (incomingRefs.length > 0) {
|
|
207
|
-
parts.push('', '## Referenced by:', '');
|
|
208
|
-
for (const ref of incomingRefs) {
|
|
209
|
-
const body = ref.section.firstParagraph
|
|
210
|
-
? ` ${s.dim('—')} ${truncate(ref.section.firstParagraph, 120)}`
|
|
211
|
-
: '';
|
|
212
|
-
parts.push(`${s.dim('*')} [[${formatSectionId(ref.section.id, s)}]]${body}`);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
if (codeRefs.length > 0) {
|
|
216
|
-
parts.push('', '## Referenced by code:', '');
|
|
217
|
-
for (const ref of codeRefs) {
|
|
218
|
-
const codeRelPath = relative(process.cwd(), join(ctx.projectRoot, ref.file));
|
|
219
|
-
parts.push(`${s.dim('*')} ${s.cyan(codeRelPath)}${s.dim(`:${ref.line}`)}`);
|
|
220
|
-
if (ref.snippet) {
|
|
221
|
-
const snippetLines = ref.snippet.split('\n');
|
|
222
|
-
for (const line of snippetLines) {
|
|
223
|
-
parts.push(` ${s.dim('|')} ${line}`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
parts.push(formatNavHints(ctx));
|
|
229
|
-
return parts.join('\n');
|
|
230
|
-
}
|
|
231
|
-
export async function sectionCommand(ctx, query) {
|
|
232
|
-
const result = await getSection(ctx, query);
|
|
233
|
-
if (result.kind === 'no-match') {
|
|
234
|
-
const s = ctx.styler;
|
|
235
|
-
if (result.suggestions.length > 0) {
|
|
236
|
-
const suggestions = result.suggestions
|
|
237
|
-
.map((m) => ` ${s.dim('*')} ${s.white(m.section.id)} ${s.dim(`(${m.reason})`)}`)
|
|
238
|
-
.join('\n');
|
|
239
|
-
return {
|
|
240
|
-
output: s.red(`No section "${query}" found.`) +
|
|
241
|
-
' Did you mean:\n' +
|
|
242
|
-
suggestions,
|
|
243
|
-
isError: true,
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
return {
|
|
247
|
-
output: s.red(`No sections matching "${query}"`),
|
|
248
|
-
isError: true,
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
return { output: formatSectionOutput(ctx, result) };
|
|
252
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface SelectOption {
|
|
2
|
-
label: string;
|
|
3
|
-
value: string;
|
|
4
|
-
/** If true, this option uses a distinct highlight style (e.g. for "done" actions). */
|
|
5
|
-
accent?: boolean;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Display an interactive select menu with arrow-key navigation.
|
|
9
|
-
* Returns the selected option's value, or null if the user pressed Ctrl+C.
|
|
10
|
-
*
|
|
11
|
-
* @param defaultIndex - initial cursor position (defaults to 0)
|
|
12
|
-
*/
|
|
13
|
-
export declare function selectMenu(options: SelectOption[], prompt?: string, defaultIndex?: number): Promise<string | null>;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { styleText } from 'node:util';
|
|
2
|
-
/**
|
|
3
|
-
* Display an interactive select menu with arrow-key navigation.
|
|
4
|
-
* Returns the selected option's value, or null if the user pressed Ctrl+C.
|
|
5
|
-
*
|
|
6
|
-
* @param defaultIndex - initial cursor position (defaults to 0)
|
|
7
|
-
*/
|
|
8
|
-
export async function selectMenu(options, prompt, defaultIndex) {
|
|
9
|
-
if (options.length === 0)
|
|
10
|
-
return null;
|
|
11
|
-
if (!process.stdin.isTTY) {
|
|
12
|
-
// Non-interactive fallback: return first option
|
|
13
|
-
return options[0].value;
|
|
14
|
-
}
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
let cursor = defaultIndex ?? 0;
|
|
17
|
-
const stdin = process.stdin;
|
|
18
|
-
// Save original stdin state
|
|
19
|
-
const wasRaw = stdin.isRaw;
|
|
20
|
-
stdin.setRawMode(true);
|
|
21
|
-
stdin.resume();
|
|
22
|
-
stdin.setEncoding('utf-8');
|
|
23
|
-
function render() {
|
|
24
|
-
process.stdout.write('\x1B[?25l'); // hide cursor
|
|
25
|
-
const lines = [];
|
|
26
|
-
if (prompt) {
|
|
27
|
-
lines.push(styleText('bold', prompt));
|
|
28
|
-
}
|
|
29
|
-
for (let i = 0; i < options.length; i++) {
|
|
30
|
-
const opt = options[i];
|
|
31
|
-
const selected = i === cursor;
|
|
32
|
-
const pointer = selected ? '❯' : ' ';
|
|
33
|
-
if (selected) {
|
|
34
|
-
if (opt.accent) {
|
|
35
|
-
lines.push(` ${pointer} ${styleText(['bgGreen', 'black', 'bold'], ` ${opt.label} `)}`);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
lines.push(` ${pointer} ${styleText(['bgCyan', 'black', 'bold'], ` ${opt.label} `)}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
lines.push(` ${pointer} ${styleText('dim', opt.label)}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
process.stdout.write(lines.join('\n') + '\n');
|
|
46
|
-
}
|
|
47
|
-
function clearRender() {
|
|
48
|
-
const totalLines = options.length + (prompt ? 1 : 0);
|
|
49
|
-
// Move up and clear each line
|
|
50
|
-
for (let i = 0; i < totalLines; i++) {
|
|
51
|
-
process.stdout.write('\x1B[A\x1B[2K');
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function cleanup() {
|
|
55
|
-
stdin.setRawMode(wasRaw ?? false);
|
|
56
|
-
stdin.pause();
|
|
57
|
-
process.stdout.write('\x1B[?25h'); // show cursor
|
|
58
|
-
stdin.removeListener('data', onData);
|
|
59
|
-
}
|
|
60
|
-
function onData(data) {
|
|
61
|
-
const key = data.toString();
|
|
62
|
-
// Ctrl+C
|
|
63
|
-
if (key === '\x03') {
|
|
64
|
-
clearRender();
|
|
65
|
-
cleanup();
|
|
66
|
-
console.log('');
|
|
67
|
-
process.exit(130);
|
|
68
|
-
}
|
|
69
|
-
// Enter
|
|
70
|
-
if (key === '\r' || key === '\n') {
|
|
71
|
-
clearRender();
|
|
72
|
-
cleanup();
|
|
73
|
-
const selected = options[cursor];
|
|
74
|
-
// Print the selection
|
|
75
|
-
if (prompt) {
|
|
76
|
-
console.log(styleText('bold', prompt) +
|
|
77
|
-
' ' +
|
|
78
|
-
styleText('green', selected.label));
|
|
79
|
-
}
|
|
80
|
-
resolve(selected.value);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
// Arrow keys (escape sequences)
|
|
84
|
-
if (key === '\x1B[A' || key === 'k') {
|
|
85
|
-
// Up
|
|
86
|
-
clearRender();
|
|
87
|
-
cursor = (cursor - 1 + options.length) % options.length;
|
|
88
|
-
render();
|
|
89
|
-
}
|
|
90
|
-
else if (key === '\x1B[B' || key === 'j') {
|
|
91
|
-
// Down
|
|
92
|
-
clearRender();
|
|
93
|
-
cursor = (cursor + 1) % options.length;
|
|
94
|
-
render();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
stdin.on('data', onData);
|
|
98
|
-
render();
|
|
99
|
-
});
|
|
100
|
-
}
|
package/dist/src/code-refs.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** Walk project files for code-ref scanning. Uses walkEntries for .gitignore
|
|
2
|
-
* support, then additionally skips .md files, lat.md/, .claude/, and sub-projects. */
|
|
3
|
-
export declare function walkFiles(dir: string): Promise<string[]>;
|
|
4
|
-
export declare const LAT_REF_RE: RegExp;
|
|
5
|
-
export type CodeRef = {
|
|
6
|
-
target: string;
|
|
7
|
-
file: string;
|
|
8
|
-
line: number;
|
|
9
|
-
};
|
|
10
|
-
export type ScanResult = {
|
|
11
|
-
refs: CodeRef[];
|
|
12
|
-
files: string[];
|
|
13
|
-
usedRg: boolean;
|
|
14
|
-
};
|
|
15
|
-
/** Check whether ripgrep (`rg`) is available on PATH. */
|
|
16
|
-
export declare function hasRipgrep(): Promise<boolean>;
|
|
17
|
-
export declare function scanCodeRefs(projectRoot: string): Promise<ScanResult>;
|