@plebeiantech/lat.md 0.12.3-fork.2 → 0.12.3-fork.21
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 +115 -64
- 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 +200 -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-0bPe_Q5I.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-1_8mI7lO.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-BLIuikwY.js +1 -0
- package/dist/src/view/client/assets/arc-D4PzdKSA.js +1 -0
- package/dist/src/view/client/assets/architectureDiagram-5GKGNRK7-35Egww62.js +36 -0
- package/dist/src/view/client/assets/blockDiagram-I7D4REHJ-tqNy53-W.js +129 -0
- package/dist/src/view/client/assets/c4Diagram-7LVT6UL2-DZ_GcD9K.js +38 -0
- package/dist/src/view/client/assets/channel-DensupHE.js +1 -0
- package/dist/src/view/client/assets/chunk-2Q5K7J3B-BUjq4Q7b.js +1 -0
- package/dist/src/view/client/assets/chunk-5VM5RSS4-BsIix6I5.js +15 -0
- package/dist/src/view/client/assets/chunk-F27PBJKO-Dxo7UheG.js +1 -0
- package/dist/src/view/client/assets/chunk-IMKFNOWR-C5lzUDK5.js +231 -0
- package/dist/src/view/client/assets/chunk-JWPE2WC7-qCHQlKfY.js +1 -0
- package/dist/src/view/client/assets/chunk-POPQ4Y6H-CDPKw21I.js +1 -0
- package/dist/src/view/client/assets/chunk-SVP7TREG-CD_C-9M-.js +88 -0
- package/dist/src/view/client/assets/chunk-TICWLB2K-ZMatRvad.js +206 -0
- package/dist/src/view/client/assets/chunk-XXDRQBXY-dDs4quwg.js +1 -0
- package/dist/src/view/client/assets/classDiagram-ZZMXUADV-CV7ArHLW.js +1 -0
- package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-CV7ArHLW.js +1 -0
- package/dist/src/view/client/assets/cose-bilkent-JH36ORCC-CwH3-T1N.js +1 -0
- package/dist/src/view/client/assets/cynefin-OW5HDTMX-DodS6r00.js +166 -0
- package/dist/src/view/client/assets/cynefinDiagram-5FMLGOSQ-D7WDoy0K.js +62 -0
- package/dist/src/view/client/assets/cytoscape.esm-DzSz-X2X.js +321 -0
- package/dist/src/view/client/assets/dagre-GXQ25YYZ-yc2GTi5h.js +4 -0
- package/dist/src/view/client/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/src/view/client/assets/diagram-S7CK7UJ4-CEP0FGL8.js +30 -0
- package/dist/src/view/client/assets/diagram-UQ7AKVKN-BZIEojBf.js +41 -0
- package/dist/src/view/client/assets/diagram-VSXAHHWV-BSB6COmM.js +3 -0
- package/dist/src/view/client/assets/diagram-VX7I27RA-DqfR3psV.js +24 -0
- package/dist/src/view/client/assets/diagram-Z3DM3KII-B79t0s5P.js +24 -0
- package/dist/src/view/client/assets/ebnfDiagram-PWID7BFC-CqbCQhE1.js +1 -0
- package/dist/src/view/client/assets/erDiagram-RLTQ6QDP-BVfoYIhJ.js +99 -0
- package/dist/src/view/client/assets/flowDiagram-HODETNUW-Dfyjm6ib.js +168 -0
- package/dist/src/view/client/assets/ganttDiagram-EL5Y4UJY-Da9ta_k3.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-BDqlQ6LG.js +106 -0
- package/dist/src/view/client/assets/index-BnENo9bV.js +1 -0
- package/dist/src/view/client/assets/index-DG0Ez15D.css +1 -0
- package/dist/src/view/client/assets/index-heNSjszK.js +13 -0
- package/dist/src/view/client/assets/infoDiagram-27XIBGKW-CozIUYm1.js +2 -0
- package/dist/src/view/client/assets/init-Gi6I4Gst.js +1 -0
- package/dist/src/view/client/assets/ishikawaDiagram-5VMMS53U-tkBLr-Tn.js +70 -0
- package/dist/src/view/client/assets/journeyDiagram-3NMN7TZE-Dcd_Ofwc.js +139 -0
- package/dist/src/view/client/assets/kanban-definition-UXKFOSKX-CQvZmdAf.js +89 -0
- package/dist/src/view/client/assets/katex-HP8lGamR.js +257 -0
- package/dist/src/view/client/assets/layout-BxuGL0Ip.js +1 -0
- package/dist/src/view/client/assets/linear-D8tR6G5K.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-BlHZooLK.js +310 -0
- package/dist/src/view/client/assets/mindmap-definition-YA3MSWOX-BqvVz5lC.js +96 -0
- package/dist/src/view/client/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/src/view/client/assets/pegDiagram-XKGWAZYB-BkbOOTxX.js +1 -0
- package/dist/src/view/client/assets/pieDiagram-E7YTZNPT-BToTpG0m.js +39 -0
- package/dist/src/view/client/assets/quadrantDiagram-AXDQQJYC-CerD2TfT.js +7 -0
- package/dist/src/view/client/assets/railroadDiagram-O6MQD6OU-B2oElPYD.js +1 -0
- package/dist/src/view/client/assets/requirementDiagram-BXWQKSXE-BCL8RGFd.js +84 -0
- package/dist/src/view/client/assets/sankeyDiagram-P5KCCOFB-BqnkNRPm.js +40 -0
- package/dist/src/view/client/assets/sequenceDiagram-WJ2MYXX4-DKSKYknp.js +162 -0
- package/dist/src/view/client/assets/sizeCapture-INFHLROL-D8reQ7IM.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-D77RDMKH-B-Eme-BN.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-yXL-Y-Ym.js +1 -0
- package/dist/src/view/client/assets/swimlanes-42K2YHIH-lK0158X4.js +1 -0
- package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-CGn5WOGw.js +8 -0
- package/dist/src/view/client/assets/three.module-PDSP0dbZ.js +4108 -0
- package/dist/src/view/client/assets/timeline-definition-24CTP7MA-imh-edhJ.js +120 -0
- package/dist/src/view/client/assets/vennDiagram-4TSXK5OY-Ixwhcd6r.js +34 -0
- package/dist/src/view/client/assets/wardleyDiagram-VM6X3IG4-Cvr_zzKI.js +78 -0
- package/dist/src/view/client/assets/xychartDiagram-S5SC5T6Z-BvcmHKlQ.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 +50648 -3166
- package/dist/src/view/markdown.d.ts +8 -3
- package/dist/src/view/markdown.js +311 -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 -20
- package/templates/cursor-rules.md +14 -7
- 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
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { existsSync, openSync, readSync, closeSync, statSync } from 'node:fs';
|
|
2
|
+
import { dirname, isAbsolute, resolve } from 'node:path';
|
|
3
|
+
import { findLatticeDir, findSections, } from '@plebeiantech/lat.md-core/lattice';
|
|
4
|
+
import { commandProjectAnalysis } from '@plebeiantech/lat.md-core/project-analysis';
|
|
5
|
+
import { plainStyler, } from '@plebeiantech/lat.md-core/context';
|
|
6
|
+
import { expandPrompt } from '@plebeiantech/lat.md-core/cli/expand';
|
|
7
|
+
import { runSearch } from '../cli/search.js';
|
|
8
|
+
import { getSection, formatSectionOutput, } from '@plebeiantech/lat.md-core/cli/section';
|
|
9
|
+
import { getStopStatus, formatStopReason, } from '../cli/hook.js';
|
|
10
|
+
import { computeCommentBlock } from '../cli/comment-guard.js';
|
|
11
|
+
import { taggedDocsForFiles, federateTags } from '../knowledge/index.js';
|
|
12
|
+
import { loadSessionMarkers, saveSessionMarkers, } from '../knowledge/session.js';
|
|
13
|
+
async function readStdin(timeoutMs = 300) {
|
|
14
|
+
if (process.stdin.isTTY)
|
|
15
|
+
return '';
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
const chunks = [];
|
|
18
|
+
let timer = null;
|
|
19
|
+
const cleanup = () => {
|
|
20
|
+
if (timer)
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
try {
|
|
23
|
+
process.stdin.pause();
|
|
24
|
+
}
|
|
25
|
+
catch { }
|
|
26
|
+
process.stdin.removeListener('data', onData);
|
|
27
|
+
process.stdin.removeListener('end', onEnd);
|
|
28
|
+
process.stdin.removeListener('error', onError);
|
|
29
|
+
};
|
|
30
|
+
const onData = (chunk) => {
|
|
31
|
+
chunks.push(chunk);
|
|
32
|
+
};
|
|
33
|
+
const onEnd = () => {
|
|
34
|
+
cleanup();
|
|
35
|
+
resolve(Buffer.concat(chunks).toString('utf-8'));
|
|
36
|
+
};
|
|
37
|
+
const onError = () => {
|
|
38
|
+
cleanup();
|
|
39
|
+
resolve(Buffer.concat(chunks).toString('utf-8'));
|
|
40
|
+
};
|
|
41
|
+
timer = setTimeout(() => {
|
|
42
|
+
cleanup();
|
|
43
|
+
resolve(Buffer.concat(chunks).toString('utf-8'));
|
|
44
|
+
}, timeoutMs);
|
|
45
|
+
process.stdin.on('data', onData);
|
|
46
|
+
process.stdin.on('end', onEnd);
|
|
47
|
+
process.stdin.on('error', onError);
|
|
48
|
+
process.stdin.resume();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export function extractLastUserPrompt(transcriptPath) {
|
|
52
|
+
if (!transcriptPath || !existsSync(transcriptPath))
|
|
53
|
+
return null;
|
|
54
|
+
let fd = null;
|
|
55
|
+
try {
|
|
56
|
+
const stat = statSync(transcriptPath);
|
|
57
|
+
if (stat.size === 0)
|
|
58
|
+
return null;
|
|
59
|
+
fd = openSync(transcriptPath, 'r');
|
|
60
|
+
const chunkSize = Math.min(64 * 1024, stat.size);
|
|
61
|
+
const buffer = Buffer.alloc(chunkSize);
|
|
62
|
+
readSync(fd, buffer, 0, chunkSize, stat.size - chunkSize);
|
|
63
|
+
closeSync(fd);
|
|
64
|
+
fd = null;
|
|
65
|
+
const chunkStr = buffer.toString('utf-8');
|
|
66
|
+
const lines = chunkStr.trim().split('\n');
|
|
67
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
68
|
+
const line = lines[i].trim();
|
|
69
|
+
if (!line)
|
|
70
|
+
continue;
|
|
71
|
+
const entry = JSON.parse(line);
|
|
72
|
+
const isUser = entry.type === 'USER_INPUT' ||
|
|
73
|
+
entry.type === 'user' ||
|
|
74
|
+
entry.role === 'user';
|
|
75
|
+
if (isUser) {
|
|
76
|
+
if (typeof entry.content === 'string')
|
|
77
|
+
return entry.content;
|
|
78
|
+
if (typeof entry.text === 'string')
|
|
79
|
+
return entry.text;
|
|
80
|
+
if (typeof entry.message === 'string')
|
|
81
|
+
return entry.message;
|
|
82
|
+
if (Array.isArray(entry.content)) {
|
|
83
|
+
const text = entry.content
|
|
84
|
+
.map((p) => typeof p === 'string'
|
|
85
|
+
? p
|
|
86
|
+
: (p?.text ??
|
|
87
|
+
p?.content ??
|
|
88
|
+
''))
|
|
89
|
+
.filter(Boolean)
|
|
90
|
+
.join('\n');
|
|
91
|
+
if (text)
|
|
92
|
+
return text;
|
|
93
|
+
}
|
|
94
|
+
if (Array.isArray(entry.parts)) {
|
|
95
|
+
const text = entry.parts
|
|
96
|
+
.map((p) => typeof p === 'string'
|
|
97
|
+
? p
|
|
98
|
+
: (p?.text ??
|
|
99
|
+
p?.content ??
|
|
100
|
+
''))
|
|
101
|
+
.filter(Boolean)
|
|
102
|
+
.join('\n');
|
|
103
|
+
if (text)
|
|
104
|
+
return text;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
if (fd !== null) {
|
|
113
|
+
try {
|
|
114
|
+
closeSync(fd);
|
|
115
|
+
}
|
|
116
|
+
catch { }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
function makeHookCtx(latDir) {
|
|
122
|
+
return {
|
|
123
|
+
latDir,
|
|
124
|
+
projectRoot: dirname(latDir),
|
|
125
|
+
styler: plainStyler,
|
|
126
|
+
mode: 'cli',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export async function handleAntigravityPreInvocation(rawInput, writeOutput = true) {
|
|
130
|
+
const emptyOutput = { injectSteps: [] };
|
|
131
|
+
try {
|
|
132
|
+
const raw = rawInput ?? (await readStdin().catch(() => ''));
|
|
133
|
+
let input = {};
|
|
134
|
+
try {
|
|
135
|
+
input = JSON.parse(raw);
|
|
136
|
+
}
|
|
137
|
+
catch { }
|
|
138
|
+
const userPrompt = input.user_prompt ||
|
|
139
|
+
input.prompt ||
|
|
140
|
+
input.userPrompt ||
|
|
141
|
+
extractLastUserPrompt(input.transcriptPath) ||
|
|
142
|
+
'';
|
|
143
|
+
const workspacePaths = input.workspacePaths ??
|
|
144
|
+
input.workspace_paths;
|
|
145
|
+
const latDir = findLatticeDir(workspacePaths?.[0]) ?? findLatticeDir();
|
|
146
|
+
if (!latDir) {
|
|
147
|
+
if (writeOutput)
|
|
148
|
+
process.stdout.write(JSON.stringify(emptyOutput) + '\n');
|
|
149
|
+
return emptyOutput;
|
|
150
|
+
}
|
|
151
|
+
const ctx = makeHookCtx(latDir);
|
|
152
|
+
const parts = [];
|
|
153
|
+
const searchFilePaths = [];
|
|
154
|
+
if (userPrompt) {
|
|
155
|
+
// Memoised on ctx, so the expansion, search, and federation below
|
|
156
|
+
// share one parse of the tree — same contract as cli/hook.ts.
|
|
157
|
+
const allSections = await commandProjectAnalysis(ctx)
|
|
158
|
+
.then((analysis) => analysis.allSections)
|
|
159
|
+
.catch(() => []);
|
|
160
|
+
if (/\[\[[^\]]+\]\]/.test(userPrompt)) {
|
|
161
|
+
try {
|
|
162
|
+
const expanded = await expandPrompt(ctx, userPrompt);
|
|
163
|
+
if (expanded && expanded !== userPrompt) {
|
|
164
|
+
parts.push(expanded, '');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch { }
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
const searchResult = await runSearch(ctx.latDir, userPrompt, 5, undefined, {
|
|
171
|
+
buildIndex: false,
|
|
172
|
+
});
|
|
173
|
+
if (searchResult.matches.length > 0) {
|
|
174
|
+
parts.push(`Search results for user prompt (${searchResult.matches.length} matches):`, '');
|
|
175
|
+
for (const match of searchResult.matches) {
|
|
176
|
+
searchFilePaths.push(match.section.filePath);
|
|
177
|
+
const sectionResult = await getSection(ctx, match.section.id);
|
|
178
|
+
if (sectionResult.kind === 'found') {
|
|
179
|
+
parts.push(formatSectionOutput(ctx, sectionResult));
|
|
180
|
+
parts.push('');
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch { }
|
|
186
|
+
try {
|
|
187
|
+
const filePaths = [];
|
|
188
|
+
const refTargets = [...userPrompt.matchAll(/\[\[([^\]]+)\]\]/g)].map((m) => m[1]);
|
|
189
|
+
for (const target of refTargets) {
|
|
190
|
+
const matches = findSections(allSections, target);
|
|
191
|
+
if (matches.length > 0) {
|
|
192
|
+
filePaths.push(matches[0].section.filePath);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
filePaths.push(...searchFilePaths);
|
|
196
|
+
if (filePaths.length > 0) {
|
|
197
|
+
const docs = await taggedDocsForFiles(ctx.projectRoot, filePaths);
|
|
198
|
+
const sessionId = input.conversationId ??
|
|
199
|
+
input.conversation_id ??
|
|
200
|
+
input.session_id ??
|
|
201
|
+
'';
|
|
202
|
+
const sessionMarkers = loadSessionMarkers(sessionId);
|
|
203
|
+
const federated = await federateTags(docs, {
|
|
204
|
+
projectRoot: ctx.projectRoot,
|
|
205
|
+
seen: sessionMarkers.markers.seen,
|
|
206
|
+
attemptedEmpty: sessionMarkers.markers.attemptedEmpty,
|
|
207
|
+
});
|
|
208
|
+
saveSessionMarkers(sessionMarkers);
|
|
209
|
+
if (federated) {
|
|
210
|
+
parts.push('', federated);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch { }
|
|
215
|
+
}
|
|
216
|
+
parts.push('Review whether `lat.md/` needs a current-state update; do not add journal/changelog notes just to satisfy this reminder. Run `lat search` to find relevant sections and `lat check` at the end.');
|
|
217
|
+
const output = {
|
|
218
|
+
injectSteps: [
|
|
219
|
+
{
|
|
220
|
+
ephemeralMessage: parts.join('\n').trim(),
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
};
|
|
224
|
+
if (writeOutput) {
|
|
225
|
+
process.stdout.write(JSON.stringify(output) + '\n');
|
|
226
|
+
}
|
|
227
|
+
return output;
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
if (writeOutput) {
|
|
231
|
+
process.stdout.write(JSON.stringify(emptyOutput) + '\n');
|
|
232
|
+
}
|
|
233
|
+
return emptyOutput;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
export async function handleAntigravityPreToolUse(rawInput, writeOutput = true) {
|
|
237
|
+
const allow = { decision: 'allow' };
|
|
238
|
+
try {
|
|
239
|
+
const raw = rawInput ?? (await readStdin().catch(() => ''));
|
|
240
|
+
let input = {};
|
|
241
|
+
try {
|
|
242
|
+
input = JSON.parse(raw);
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
if (writeOutput)
|
|
246
|
+
process.stdout.write(JSON.stringify(allow) + '\n');
|
|
247
|
+
return allow;
|
|
248
|
+
}
|
|
249
|
+
const rawToolName = input.toolCall?.name ?? '';
|
|
250
|
+
const toolName = rawToolName.split(':').pop() ?? rawToolName;
|
|
251
|
+
const args = input.toolCall?.args ?? {};
|
|
252
|
+
let toolInput = {};
|
|
253
|
+
if (toolName === 'replace_file_content') {
|
|
254
|
+
toolInput = {
|
|
255
|
+
file_path: (args.TargetFile ??
|
|
256
|
+
args.target_file ??
|
|
257
|
+
args.filePath ??
|
|
258
|
+
args.file_path),
|
|
259
|
+
new_string: (args.ReplacementContent ??
|
|
260
|
+
args.replacement_content ??
|
|
261
|
+
args.new_string),
|
|
262
|
+
old_string: (args.TargetContent ??
|
|
263
|
+
args.target_content ??
|
|
264
|
+
args.old_string),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
else if (toolName === 'write_to_file') {
|
|
268
|
+
toolInput = {
|
|
269
|
+
file_path: (args.TargetFile ??
|
|
270
|
+
args.target_file ??
|
|
271
|
+
args.filePath ??
|
|
272
|
+
args.file_path),
|
|
273
|
+
content: (args.CodeContent ?? args.code_content ?? args.content),
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
if (writeOutput)
|
|
278
|
+
process.stdout.write(JSON.stringify(allow) + '\n');
|
|
279
|
+
return allow;
|
|
280
|
+
}
|
|
281
|
+
const cwd = input.workspacePaths?.[0] ??
|
|
282
|
+
input.workspace_paths?.[0] ??
|
|
283
|
+
process.cwd();
|
|
284
|
+
if (!toolInput.file_path) {
|
|
285
|
+
if (writeOutput)
|
|
286
|
+
process.stdout.write(JSON.stringify(allow) + '\n');
|
|
287
|
+
return allow;
|
|
288
|
+
}
|
|
289
|
+
if (!isAbsolute(toolInput.file_path)) {
|
|
290
|
+
toolInput.file_path = resolve(cwd, toolInput.file_path);
|
|
291
|
+
}
|
|
292
|
+
const reason = computeCommentBlock({
|
|
293
|
+
tool_name: toolName === 'replace_file_content' ? 'Edit' : 'Write',
|
|
294
|
+
tool_input: toolInput,
|
|
295
|
+
cwd,
|
|
296
|
+
});
|
|
297
|
+
if (reason) {
|
|
298
|
+
const deny = {
|
|
299
|
+
decision: 'deny',
|
|
300
|
+
reason,
|
|
301
|
+
};
|
|
302
|
+
if (writeOutput)
|
|
303
|
+
process.stdout.write(JSON.stringify(deny) + '\n');
|
|
304
|
+
return deny;
|
|
305
|
+
}
|
|
306
|
+
if (writeOutput)
|
|
307
|
+
process.stdout.write(JSON.stringify(allow) + '\n');
|
|
308
|
+
return allow;
|
|
309
|
+
}
|
|
310
|
+
catch {
|
|
311
|
+
if (writeOutput)
|
|
312
|
+
process.stdout.write(JSON.stringify(allow) + '\n');
|
|
313
|
+
return allow;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
export async function handleAntigravityPostToolUse(rawInput, writeOutput = true) {
|
|
317
|
+
const output = {};
|
|
318
|
+
try {
|
|
319
|
+
const raw = rawInput ?? (await readStdin().catch(() => ''));
|
|
320
|
+
let input = {};
|
|
321
|
+
try {
|
|
322
|
+
input = JSON.parse(raw);
|
|
323
|
+
}
|
|
324
|
+
catch { }
|
|
325
|
+
const workspacePath = input.workspacePaths?.[0] ??
|
|
326
|
+
input.workspace_paths?.[0] ??
|
|
327
|
+
input.cwd;
|
|
328
|
+
const latDir = findLatticeDir(workspacePath) ?? findLatticeDir();
|
|
329
|
+
if (latDir) {
|
|
330
|
+
try {
|
|
331
|
+
const { checkIndex } = await import('@plebeiantech/lat.md-core/cli/check');
|
|
332
|
+
await checkIndex(latDir, undefined, { fix: true });
|
|
333
|
+
}
|
|
334
|
+
catch { }
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
catch { }
|
|
338
|
+
if (writeOutput) {
|
|
339
|
+
process.stdout.write(JSON.stringify(output) + '\n');
|
|
340
|
+
}
|
|
341
|
+
return output;
|
|
342
|
+
}
|
|
343
|
+
export async function handleAntigravityStop(rawInput, writeOutput = true) {
|
|
344
|
+
const allowStop = {};
|
|
345
|
+
try {
|
|
346
|
+
const raw = rawInput ?? (await readStdin().catch(() => ''));
|
|
347
|
+
let input = {};
|
|
348
|
+
try {
|
|
349
|
+
input = JSON.parse(raw);
|
|
350
|
+
}
|
|
351
|
+
catch { }
|
|
352
|
+
const workspacePath = input.workspacePaths?.[0] ??
|
|
353
|
+
input.workspace_paths?.[0] ??
|
|
354
|
+
input.cwd;
|
|
355
|
+
const latDir = findLatticeDir(workspacePath) ?? findLatticeDir();
|
|
356
|
+
if (!latDir) {
|
|
357
|
+
if (writeOutput)
|
|
358
|
+
process.stdout.write(JSON.stringify(allowStop) + '\n');
|
|
359
|
+
return allowStop;
|
|
360
|
+
}
|
|
361
|
+
const execNum = typeof input.executionNum === 'number'
|
|
362
|
+
? input.executionNum
|
|
363
|
+
: typeof input.execution_num === 'number'
|
|
364
|
+
? input.execution_num
|
|
365
|
+
: undefined;
|
|
366
|
+
const stopHookActive = Boolean(input.stop_hook_active ||
|
|
367
|
+
input.stopHookActive ||
|
|
368
|
+
(execNum !== undefined && execNum > 1));
|
|
369
|
+
let status;
|
|
370
|
+
try {
|
|
371
|
+
status = await getStopStatus(latDir);
|
|
372
|
+
}
|
|
373
|
+
catch {
|
|
374
|
+
if (writeOutput)
|
|
375
|
+
process.stdout.write(JSON.stringify(allowStop) + '\n');
|
|
376
|
+
return allowStop;
|
|
377
|
+
}
|
|
378
|
+
const reason = formatStopReason(status);
|
|
379
|
+
if (!reason) {
|
|
380
|
+
if (writeOutput)
|
|
381
|
+
process.stdout.write(JSON.stringify(allowStop) + '\n');
|
|
382
|
+
return allowStop;
|
|
383
|
+
}
|
|
384
|
+
if (stopHookActive) {
|
|
385
|
+
console.error('Warning: `lat check` still reports errors or sync gaps, but continuing stop to prevent loop.');
|
|
386
|
+
if (writeOutput)
|
|
387
|
+
process.stdout.write(JSON.stringify(allowStop) + '\n');
|
|
388
|
+
return allowStop;
|
|
389
|
+
}
|
|
390
|
+
const output = {
|
|
391
|
+
decision: 'continue',
|
|
392
|
+
reason,
|
|
393
|
+
};
|
|
394
|
+
if (writeOutput)
|
|
395
|
+
process.stdout.write(JSON.stringify(output) + '\n');
|
|
396
|
+
return output;
|
|
397
|
+
}
|
|
398
|
+
catch {
|
|
399
|
+
if (writeOutput)
|
|
400
|
+
process.stdout.write(JSON.stringify(allowStop) + '\n');
|
|
401
|
+
return allowStop;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
export async function handleAntigravityHook(event, rawInput) {
|
|
405
|
+
const normalized = event.toLowerCase();
|
|
406
|
+
switch (normalized) {
|
|
407
|
+
case 'preinvocation':
|
|
408
|
+
case 'userpromptsubmit':
|
|
409
|
+
await handleAntigravityPreInvocation(rawInput);
|
|
410
|
+
return;
|
|
411
|
+
case 'pretooluse':
|
|
412
|
+
await handleAntigravityPreToolUse(rawInput);
|
|
413
|
+
return;
|
|
414
|
+
case 'posttooluse':
|
|
415
|
+
await handleAntigravityPostToolUse(rawInput);
|
|
416
|
+
return;
|
|
417
|
+
case 'stop':
|
|
418
|
+
await handleAntigravityStop(rawInput);
|
|
419
|
+
return;
|
|
420
|
+
default:
|
|
421
|
+
console.error(`Unknown hook event for antigravity: ${event}. Supported: PreInvocation, PreToolUse, PostToolUse, Stop`);
|
|
422
|
+
process.exit(1);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function antigravityHooksTemplate(latBin: string): string;
|
|
2
|
+
export declare function mergeAntigravityHooks(existingRaw: string | null, latBin: string): string;
|
|
3
|
+
export type SetupAntigravityOptions = {
|
|
4
|
+
root: string;
|
|
5
|
+
latDir: string;
|
|
6
|
+
template: string;
|
|
7
|
+
hashes: Record<string, string>;
|
|
8
|
+
ask: (message: string) => Promise<boolean>;
|
|
9
|
+
style: 'global' | 'local' | 'npx';
|
|
10
|
+
latBin: string;
|
|
11
|
+
appendTemplateSection: (root: string, latDir: string, relPath: string, template: string, label: string, indent: string, ask: (message: string) => Promise<boolean>) => Promise<string | null>;
|
|
12
|
+
writeTemplateFile: (root: string, latDir: string, relPath: string, template: string, genTarget: string | null, label: string, indent: string, ask: (message: string) => Promise<boolean>) => Promise<string | null>;
|
|
13
|
+
ensureGitignored: (root: string, entry: string) => void;
|
|
14
|
+
hasMcpServer: (root: string, configPath: string, key: string) => boolean;
|
|
15
|
+
addMcpServer: (root: string, configPath: string, key: string, style: 'global' | 'local' | 'npx') => void;
|
|
16
|
+
};
|
|
17
|
+
export declare function setupAntigravity(opts: SetupAntigravityOptions): Promise<void>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { styleText } from 'node:util';
|
|
4
|
+
import { readSkillTemplate } from '../cli/gen.js';
|
|
5
|
+
import { readForkConventions, SKILL_FRONTMATTER, } from '../cli/fork-instructions.js';
|
|
6
|
+
export function antigravityHooksTemplate(latBin) {
|
|
7
|
+
return (JSON.stringify({
|
|
8
|
+
'lat-md': {
|
|
9
|
+
PreInvocation: [
|
|
10
|
+
{
|
|
11
|
+
type: 'command',
|
|
12
|
+
command: `${latBin} hook antigravity PreInvocation`,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
PreToolUse: [
|
|
16
|
+
{
|
|
17
|
+
matcher: 'replace_file_content|write_to_file',
|
|
18
|
+
hooks: [
|
|
19
|
+
{
|
|
20
|
+
type: 'command',
|
|
21
|
+
command: `${latBin} hook antigravity PreToolUse`,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
PostToolUse: [
|
|
27
|
+
{
|
|
28
|
+
matcher: 'replace_file_content|write_to_file',
|
|
29
|
+
hooks: [
|
|
30
|
+
{
|
|
31
|
+
type: 'command',
|
|
32
|
+
command: `${latBin} hook antigravity PostToolUse`,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
Stop: [
|
|
38
|
+
{
|
|
39
|
+
type: 'command',
|
|
40
|
+
command: `${latBin} hook antigravity Stop`,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
}, null, 2) + '\n');
|
|
45
|
+
}
|
|
46
|
+
export function mergeAntigravityHooks(existingRaw, latBin) {
|
|
47
|
+
let config = {};
|
|
48
|
+
if (existingRaw) {
|
|
49
|
+
try {
|
|
50
|
+
const parsed = JSON.parse(existingRaw);
|
|
51
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
52
|
+
config = parsed;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
try {
|
|
57
|
+
const stripped = existingRaw
|
|
58
|
+
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
59
|
+
.replace(/\/\/.*/g, '')
|
|
60
|
+
.replace(/,\s*([}\]])/g, '$1');
|
|
61
|
+
const parsed = JSON.parse(stripped);
|
|
62
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
63
|
+
config = parsed;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
config = {};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const template = JSON.parse(antigravityHooksTemplate(latBin));
|
|
72
|
+
config['lat-md'] = template['lat-md'];
|
|
73
|
+
return JSON.stringify(config, null, 2) + '\n';
|
|
74
|
+
}
|
|
75
|
+
export async function setupAntigravity(opts) {
|
|
76
|
+
const { root, latDir, template, hashes, ask, style, latBin, appendTemplateSection, writeTemplateFile, ensureGitignored, hasMcpServer, addMcpServer, } = opts;
|
|
77
|
+
const geminiHash = await appendTemplateSection(root, latDir, 'GEMINI.md', template, 'GEMINI.md', ' ', ask);
|
|
78
|
+
if (geminiHash)
|
|
79
|
+
hashes['GEMINI.md'] = geminiHash;
|
|
80
|
+
console.log('');
|
|
81
|
+
console.log(styleText('dim', ' Antigravity hooks inject lat.md reminders into prompts, enforce the'));
|
|
82
|
+
console.log(styleText('dim', ' comment convention on edits, and block finishing on check failures.'));
|
|
83
|
+
const existingHooksPath = join(root, '.agents/hooks.json');
|
|
84
|
+
let hooksContent;
|
|
85
|
+
if (existsSync(existingHooksPath)) {
|
|
86
|
+
try {
|
|
87
|
+
const existingRaw = readFileSync(existingHooksPath, 'utf-8');
|
|
88
|
+
hooksContent = mergeAntigravityHooks(existingRaw, latBin);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
hooksContent = antigravityHooksTemplate(latBin);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
hooksContent = antigravityHooksTemplate(latBin);
|
|
96
|
+
}
|
|
97
|
+
const hooksHash = await writeTemplateFile(root, latDir, '.agents/hooks.json', hooksContent, null, 'Hooks (.agents/hooks.json)', ' ', ask);
|
|
98
|
+
if (hooksHash)
|
|
99
|
+
hashes['.agents/hooks.json'] = hooksHash;
|
|
100
|
+
console.log('');
|
|
101
|
+
console.log(styleText('dim', ' The lat-md skills teach the agent how to write and maintain lat.md/ files.'));
|
|
102
|
+
const skillTemplate = readSkillTemplate();
|
|
103
|
+
const skillHash = await writeTemplateFile(root, latDir, '.agents/skills/lat-md/SKILL.md', skillTemplate, 'skill.md', 'Skill (.agents/skills/lat-md/SKILL.md)', ' ', ask);
|
|
104
|
+
if (skillHash)
|
|
105
|
+
hashes['.agents/skills/lat-md/SKILL.md'] = skillHash;
|
|
106
|
+
try {
|
|
107
|
+
const conventionsSkill = `${SKILL_FRONTMATTER}${readForkConventions()}`;
|
|
108
|
+
const conventionsHash = await writeTemplateFile(root, latDir, '.agents/skills/lat-md-conventions/SKILL.md', conventionsSkill, 'skill.md', 'Skill (.agents/skills/lat-md-conventions/SKILL.md)', ' ', ask);
|
|
109
|
+
if (conventionsHash) {
|
|
110
|
+
hashes['.agents/skills/lat-md-conventions/SKILL.md'] = conventionsHash;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch { }
|
|
114
|
+
ensureGitignored(root, '.gemini');
|
|
115
|
+
const mcpPath = join(root, '.mcp.json');
|
|
116
|
+
if (hasMcpServer(root, mcpPath, 'mcpServers')) {
|
|
117
|
+
console.log(styleText('green', ' MCP server') + ' already configured');
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
addMcpServer(root, mcpPath, 'mcpServers', style);
|
|
121
|
+
console.log(styleText('green', ' MCP server') + ' registered in .mcp.json');
|
|
122
|
+
}
|
|
123
|
+
ensureGitignored(root, '.mcp.json');
|
|
124
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const UPSTREAM_URL = "https://github.com/vercel-labs/lat.md.git";
|
|
2
|
+
export declare const UPSTREAM_REF = "refs/remotes/upstream/main";
|
|
3
|
+
export type Drift = {
|
|
4
|
+
upstream: string;
|
|
5
|
+
ahead: number;
|
|
6
|
+
behind: number;
|
|
7
|
+
upstreamFiles: string[];
|
|
8
|
+
forkFiles: string[];
|
|
9
|
+
overlap: string[];
|
|
10
|
+
conflicts: string[];
|
|
11
|
+
mergesCleanly: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Conflicting paths from `git merge-tree --write-tree --name-only`, whose
|
|
15
|
+
* output is the written tree id, then one path per line, then a blank line
|
|
16
|
+
* and the human-readable log. Everything after that blank line is prose.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseMergeTree(stdout: string): string[];
|
|
19
|
+
export declare function fetchUpstream(repo: string, url: string, ref: string): void;
|
|
20
|
+
export declare function analyzeDrift(opts: {
|
|
21
|
+
repo: string;
|
|
22
|
+
syncPoint: string;
|
|
23
|
+
upstreamRef: string;
|
|
24
|
+
}): Drift;
|
|
25
|
+
export declare function formatDrift(drift: Drift): string;
|
|
26
|
+
export declare function main(argv: string[]): number;
|