@plebeiantech/lat.md 0.12.3-fork.13 → 0.12.3-fork.14
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 +24 -0
- package/dist/src/cli/check-context.d.ts +56 -0
- package/dist/src/cli/check-context.js +215 -0
- package/dist/src/cli/check-coverage.js +9 -5
- package/dist/src/cli/check-frontmatter.js +1 -1
- package/dist/src/cli/check-mode.js +1 -1
- package/dist/src/cli/check-status.js +1 -1
- package/dist/src/cli/check.d.ts +19 -12
- package/dist/src/cli/check.js +259 -206
- package/dist/src/cli/context.js +1 -1
- package/dist/src/cli/expand.d.ts +1 -2
- package/dist/src/cli/expand.js +52 -5
- package/dist/src/cli/external.d.ts +11 -0
- package/dist/src/cli/external.js +185 -0
- package/dist/src/cli/fork-instructions.d.ts +1 -0
- package/dist/src/cli/fork-instructions.js +3 -2
- package/dist/src/cli/hook.d.ts +26 -0
- package/dist/src/cli/hook.js +112 -40
- package/dist/src/cli/index.js +55 -3
- package/dist/src/cli/init.d.ts +1 -0
- package/dist/src/cli/init.js +40 -2
- package/dist/src/cli/locate.js +4 -3
- package/dist/src/cli/refs.d.ts +2 -1
- package/dist/src/cli/refs.js +88 -43
- package/dist/src/cli/reindex.js +2 -1
- package/dist/src/cli/search.d.ts +12 -3
- package/dist/src/cli/search.js +45 -49
- package/dist/src/cli/section.d.ts +3 -1
- package/dist/src/cli/section.js +114 -38
- package/dist/src/code-refs.d.ts +17 -5
- package/dist/src/code-refs.js +246 -65
- package/dist/src/context.d.ts +3 -0
- package/dist/src/document-formats.d.ts +7 -0
- package/dist/src/document-formats.js +39 -0
- package/dist/src/extensions/alert-marker.d.ts +25 -0
- package/dist/src/extensions/alert-marker.js +55 -0
- package/dist/src/external-documents.d.ts +56 -0
- package/dist/src/external-documents.js +404 -0
- package/dist/src/external-sources.d.ts +136 -0
- package/dist/src/external-sources.js +1098 -0
- package/dist/src/fork/antigravity-hook.d.ts +47 -0
- package/dist/src/fork/antigravity-hook.js +424 -0
- package/dist/src/fork/antigravity-init.d.ts +17 -0
- package/dist/src/fork/antigravity-init.js +124 -0
- package/dist/src/fork/frontmatter-fields.d.ts +36 -0
- package/dist/src/fork/frontmatter-fields.js +23 -0
- package/dist/src/format.d.ts +5 -2
- package/dist/src/format.js +8 -3
- package/dist/src/graph-export.js +1 -1
- package/dist/src/lattice-model.d.ts +77 -0
- package/dist/src/lattice-model.js +464 -0
- package/dist/src/lattice.d.ts +9 -104
- package/dist/src/lattice.js +69 -516
- package/dist/src/markdown-analysis-cache.d.ts +20 -0
- package/dist/src/markdown-analysis-cache.js +139 -0
- package/dist/src/markdown-analysis-worker.d.ts +16 -0
- package/dist/src/markdown-analysis-worker.js +33 -0
- package/dist/src/markdown-analysis.d.ts +50 -0
- package/dist/src/markdown-analysis.js +139 -0
- package/dist/src/markdown-analyzer-loader.d.ts +4 -0
- package/dist/src/markdown-analyzer-loader.js +13 -0
- package/dist/src/markdown-validation.d.ts +25 -0
- package/dist/src/markdown-validation.js +104 -0
- package/dist/src/mcp/server.js +27 -11
- package/dist/src/parser-cache.d.ts +17 -0
- package/dist/src/parser-cache.js +65 -0
- package/dist/src/parser-import.d.ts +8 -0
- package/dist/src/parser-import.js +1 -0
- package/dist/src/parser.js +80 -5
- package/dist/src/path.d.ts +2 -0
- package/dist/src/path.js +4 -0
- package/dist/src/profiler.d.ts +16 -0
- package/dist/src/profiler.js +81 -0
- package/dist/src/project-analysis.d.ts +59 -0
- package/dist/src/project-analysis.js +233 -0
- package/dist/src/project-discovery.d.ts +6 -0
- package/dist/src/project-discovery.js +30 -0
- package/dist/src/repository-path.d.ts +11 -0
- package/dist/src/repository-path.js +52 -0
- package/dist/src/search/db.d.ts +1 -1
- package/dist/src/search/db.js +2 -2
- package/dist/src/search/embedder.d.ts +2 -1
- package/dist/src/search/embedder.js +6 -5
- package/dist/src/search/index.d.ts +2 -1
- package/dist/src/search/index.js +10 -8
- package/dist/src/search/query.d.ts +20 -0
- package/dist/src/search/query.js +67 -0
- package/dist/src/search/search.d.ts +3 -1
- package/dist/src/search/search.js +5 -2
- package/dist/src/source-formats.d.ts +7 -0
- package/dist/src/source-formats.js +26 -0
- package/dist/src/source-parser.d.ts +44 -4
- package/dist/src/source-parser.js +494 -57
- 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-B7quqPb8.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/abnfDiagram-VCTEODGH-V7-T6qsl.js +1 -0
- package/dist/src/view/client/assets/arc-BnwR8Bu7.js +1 -0
- package/dist/src/view/client/assets/architectureDiagram-5GKGNRK7-u97vDna9.js +36 -0
- package/dist/src/view/client/assets/blockDiagram-I7D4REHJ-DETl8e_H.js +129 -0
- package/dist/src/view/client/assets/c4Diagram-7LVT6UL2-DJRAT1Ve.js +38 -0
- package/dist/src/view/client/assets/channel-BwQbnWCN.js +1 -0
- package/dist/src/view/client/assets/chunk-2Q5K7J3B-C0TmOC1Q.js +1 -0
- package/dist/src/view/client/assets/chunk-5VM5RSS4-dfBOrYE6.js +15 -0
- package/dist/src/view/client/assets/chunk-F27PBJKO-DAnks99K.js +1 -0
- package/dist/src/view/client/assets/chunk-IMKFNOWR-CPjB07if.js +231 -0
- package/dist/src/view/client/assets/chunk-JWPE2WC7-VvU_gZI6.js +1 -0
- package/dist/src/view/client/assets/chunk-POPQ4Y6H-DDUbVF55.js +1 -0
- package/dist/src/view/client/assets/chunk-SVP7TREG-BHROkr6D.js +88 -0
- package/dist/src/view/client/assets/chunk-TICWLB2K-95PzGIOg.js +206 -0
- package/dist/src/view/client/assets/chunk-XXDRQBXY-MdmuLhIs.js +1 -0
- package/dist/src/view/client/assets/classDiagram-ZZMXUADV-HvQKkIS-.js +1 -0
- package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-HvQKkIS-.js +1 -0
- package/dist/src/view/client/assets/cose-bilkent-JH36ORCC-CauUf_rN.js +1 -0
- package/dist/src/view/client/assets/cynefin-OW5HDTMX-CeA8IKWo.js +166 -0
- package/dist/src/view/client/assets/cynefinDiagram-5FMLGOSQ-L1rtcT8l.js +62 -0
- package/dist/src/view/client/assets/cytoscape.esm-DzSz-X2X.js +321 -0
- package/dist/src/view/client/assets/dagre-GXQ25YYZ-DLQwTa3H.js +4 -0
- package/dist/src/view/client/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/src/view/client/assets/diagram-S7CK7UJ4-kbKdIyXG.js +30 -0
- package/dist/src/view/client/assets/diagram-UQ7AKVKN-kmzp92RC.js +41 -0
- package/dist/src/view/client/assets/diagram-VSXAHHWV-EXJTU8qq.js +3 -0
- package/dist/src/view/client/assets/diagram-VX7I27RA-DAiIyMCG.js +24 -0
- package/dist/src/view/client/assets/diagram-Z3DM3KII-G9wz50ZV.js +24 -0
- package/dist/src/view/client/assets/ebnfDiagram-PWID7BFC-D2tVRCNA.js +1 -0
- package/dist/src/view/client/assets/erDiagram-RLTQ6QDP-C925J5A3.js +99 -0
- package/dist/src/view/client/assets/flowDiagram-HODETNUW-DzoCa-Nq.js +168 -0
- package/dist/src/view/client/assets/ganttDiagram-EL5Y4UJY-D2ebbg4p.js +292 -0
- package/dist/src/view/client/assets/gitGraphDiagram-WWUBYQGX-B4QratYy.js +106 -0
- package/dist/src/view/client/assets/index-BnENo9bV.js +1 -0
- package/dist/src/view/client/assets/index-D0ajr_Ja.css +1 -0
- package/dist/src/view/client/assets/index-KZcnpXJH.js +321 -0
- package/dist/src/view/client/assets/infoDiagram-27XIBGKW-DL4mtHkt.js +2 -0
- package/dist/src/view/client/assets/init-Gi6I4Gst.js +1 -0
- package/dist/src/view/client/assets/ishikawaDiagram-5VMMS53U-CW4mto2d.js +70 -0
- package/dist/src/view/client/assets/journeyDiagram-3NMN7TZE-8R4eacFW.js +139 -0
- package/dist/src/view/client/assets/kanban-definition-UXKFOSKX-Cy9ioXEJ.js +89 -0
- package/dist/src/view/client/assets/katex-HP8lGamR.js +257 -0
- package/dist/src/view/client/assets/layout-C0MFuhth.js +1 -0
- package/dist/src/view/client/assets/linear-Dv3N4dQR.js +1 -0
- package/dist/src/view/client/assets/logo-small-RR_KBOAT.svg +149 -0
- package/dist/src/view/client/assets/maplibre-gl-DnqZgfUS.js +800 -0
- package/dist/src/view/client/assets/mermaid.core-bds9A7e2.js +310 -0
- package/dist/src/view/client/assets/mindmap-definition-YA3MSWOX-DjmGW355.js +96 -0
- package/dist/src/view/client/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/src/view/client/assets/pegDiagram-XKGWAZYB-BWsZp0ab.js +1 -0
- package/dist/src/view/client/assets/pieDiagram-E7YTZNPT-CCH2gGR-.js +39 -0
- package/dist/src/view/client/assets/quadrantDiagram-AXDQQJYC-CjocPJFz.js +7 -0
- package/dist/src/view/client/assets/railroadDiagram-O6MQD6OU-BjLeb2KF.js +1 -0
- package/dist/src/view/client/assets/requirementDiagram-BXWQKSXE-Ct6AoXRr.js +84 -0
- package/dist/src/view/client/assets/sankeyDiagram-P5KCCOFB-CIpgGN_w.js +40 -0
- package/dist/src/view/client/assets/sequenceDiagram-WJ2MYXX4-DrmLFj6w.js +162 -0
- package/dist/src/view/client/assets/sizeCapture-INFHLROL-BdFMe2Lr.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-D77RDMKH-Zd9F1goW.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-ByIKCftl.js +1 -0
- package/dist/src/view/client/assets/swimlanes-42K2YHIH-a7VFwi00.js +1 -0
- package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-CzxaUHB-.js +8 -0
- package/dist/src/view/client/assets/three.module-PDSP0dbZ.js +4108 -0
- package/dist/src/view/client/assets/timeline-definition-24CTP7MA-BExPu6X5.js +120 -0
- package/dist/src/view/client/assets/vennDiagram-4TSXK5OY-PC1MU3si.js +34 -0
- package/dist/src/view/client/assets/wardleyDiagram-VM6X3IG4-DNWqU3fa.js +78 -0
- package/dist/src/view/client/assets/xychartDiagram-S5SC5T6Z-E1uA28_D.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 +12 -0
- package/dist/src/view/document-route.js +93 -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 +187 -0
- package/dist/src/view/git.js +1 -1
- package/dist/src/view/graph.d.ts +3 -2
- package/dist/src/view/graph.js +94 -7
- package/dist/src/view/highlight.d.ts +10 -2
- package/dist/src/view/highlight.js +4540 -1360
- package/dist/src/view/markdown.d.ts +3 -2
- package/dist/src/view/markdown.js +214 -53
- package/dist/src/view/protocol.d.ts +59 -6
- package/dist/src/view/references.d.ts +10 -25
- package/dist/src/view/references.js +117 -107
- package/dist/src/view/repository.d.ts +13 -3
- package/dist/src/view/repository.js +234 -15
- package/dist/src/view/search.d.ts +1 -1
- package/dist/src/view/search.js +3 -7
- package/dist/src/view/server.d.ts +11 -2
- package/dist/src/view/server.js +212 -70
- package/dist/src/view/source-target.js +5 -8
- package/dist/src/view/static-build.d.ts +1 -0
- package/dist/src/view/static-build.js +245 -42
- package/dist/src/view/static-protocol.d.ts +19 -2
- package/dist/src/view/store.d.ts +16 -3
- package/dist/src/view/store.js +228 -36
- package/dist/src/view/table-of-contents.d.ts +2 -2
- package/dist/src/view/table-of-contents.js +2 -22
- package/dist/src/walk.d.ts +5 -3
- package/dist/src/walk.js +102 -8
- package/package.json +46 -8
- 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 +15 -3
- package/templates/cursor-rules.md +12 -3
- package/templates/skill/SKILL.md +22 -1
- package/dist/src/view/client/assets/index-C3iaZyYT.css +0 -1
- package/dist/src/view/client/assets/index-KWi67IMz.js +0 -334
- package/dist/src/view/client/assets/logo-CNF8zs47.svg +0 -182
package/dist/src/search/db.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Client } from '@libsql/client';
|
|
2
|
-
export declare function openDb(latDir: string): Client;
|
|
2
|
+
export declare function openDb(latDir: string, requestedCacheDir?: string): Client;
|
|
3
3
|
/** Create the `meta` key/value table if absent. */
|
|
4
4
|
export declare function ensureMeta(db: Client): Promise<void>;
|
|
5
5
|
/**
|
package/dist/src/search/db.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createClient } from '@libsql/client';
|
|
2
2
|
import { mkdirSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
export function openDb(latDir) {
|
|
5
|
-
const cacheDir = join(latDir, '.cache');
|
|
4
|
+
export function openDb(latDir, requestedCacheDir) {
|
|
5
|
+
const cacheDir = requestedCacheDir ?? join(latDir, '.cache');
|
|
6
6
|
mkdirSync(cacheDir, { recursive: true });
|
|
7
7
|
const client = createClient({
|
|
8
8
|
url: `file:${join(cacheDir, 'vectors.db')}`,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EmbeddingAuthError, type Embedder } from '@lat.md/embed';
|
|
2
2
|
export type { Embedder };
|
|
3
3
|
export { EmbeddingAuthError };
|
|
4
|
+
export type CreateSearchEngine = (key?: string) => Promise<Embedder>;
|
|
4
5
|
/** `meta.embedding_model` value for an embedder, e.g. `local:minilm-l6-v2:384`. */
|
|
5
6
|
export declare function modelKey(embedder: Embedder): string;
|
|
6
7
|
/** Thrown when the stored index can't be served by the current environment and
|
|
@@ -22,4 +23,4 @@ export declare function localEmbedder(): Promise<Embedder>;
|
|
|
22
23
|
* regenerable `.cache` was wiped) the durable per-repo preference wins over the
|
|
23
24
|
* env, so a repo switched to local stays local across cache loss.
|
|
24
25
|
*/
|
|
25
|
-
export declare function embedderForIndex(storedModel: string | null, latDir: string): Promise<Embedder>;
|
|
26
|
+
export declare function embedderForIndex(storedModel: string | null, latDir: string, createSearchEngine?: CreateSearchEngine): Promise<Embedder>;
|
|
@@ -2,6 +2,7 @@ import { createEmbedder, EmbeddingAuthError, } from '@lat.md/embed';
|
|
|
2
2
|
import minilm from '@lat.md/embed-minilm-fp16';
|
|
3
3
|
import { getLlmKey, getRepoEmbedding } from '../config.js';
|
|
4
4
|
export { EmbeddingAuthError };
|
|
5
|
+
const defaultCreateSearchEngine = (key) => key ? createEmbedder({ key }) : createEmbedder({ model: minilm });
|
|
5
6
|
/** `meta.embedding_model` value for an embedder, e.g. `local:minilm-l6-v2:384`. */
|
|
6
7
|
export function modelKey(embedder) {
|
|
7
8
|
return `${embedder.name}:${embedder.dimensions}`;
|
|
@@ -33,15 +34,15 @@ export function localEmbedder() {
|
|
|
33
34
|
* regenerable `.cache` was wiped) the durable per-repo preference wins over the
|
|
34
35
|
* env, so a repo switched to local stays local across cache loss.
|
|
35
36
|
*/
|
|
36
|
-
export async function embedderForIndex(storedModel, latDir) {
|
|
37
|
+
export async function embedderForIndex(storedModel, latDir, createSearchEngine = defaultCreateSearchEngine) {
|
|
37
38
|
if (storedModel === null) {
|
|
38
39
|
if (getRepoEmbedding(latDir) === 'local')
|
|
39
|
-
return
|
|
40
|
+
return createSearchEngine();
|
|
40
41
|
// No durable preference — decide from the environment, record it later.
|
|
41
|
-
return
|
|
42
|
+
return createSearchEngine(getLlmKey());
|
|
42
43
|
}
|
|
43
44
|
if (storedModel.startsWith('local:')) {
|
|
44
|
-
return
|
|
45
|
+
return createSearchEngine(); // ignores LAT_LLM_KEY entirely
|
|
45
46
|
}
|
|
46
47
|
// Remote-pinned index: needs a key that resolves to the same model.
|
|
47
48
|
const key = getLlmKey();
|
|
@@ -49,7 +50,7 @@ export async function embedderForIndex(storedModel, latDir) {
|
|
|
49
50
|
throw new ReindexRequiredError(`This index was built with '${storedModel}', but no LAT_LLM_KEY is set. ` +
|
|
50
51
|
`Run 'lat reindex' to switch to the local model or restore the key.`);
|
|
51
52
|
}
|
|
52
|
-
const embedder = await
|
|
53
|
+
const embedder = await createSearchEngine(key);
|
|
53
54
|
if (modelKey(embedder) !== storedModel) {
|
|
54
55
|
throw new ReindexRequiredError(`This index was built with '${storedModel}', but the current key resolves ` +
|
|
55
56
|
`to '${modelKey(embedder)}'. Run 'lat reindex' to rebuild.`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Client } from '@libsql/client';
|
|
2
|
+
import { type MarkdownProjectAnalysis } from '../project-analysis.js';
|
|
2
3
|
import type { Embedder } from './embedder.js';
|
|
3
4
|
export type IndexStats = {
|
|
4
5
|
added: number;
|
|
@@ -6,4 +7,4 @@ export type IndexStats = {
|
|
|
6
7
|
removed: number;
|
|
7
8
|
unchanged: number;
|
|
8
9
|
};
|
|
9
|
-
export declare function indexSections(latDir: string, db: Client, embedder: Embedder, onProgress?: (done: number, total: number) => void): Promise<IndexStats>;
|
|
10
|
+
export declare function indexSections(latDir: string, db: Client, embedder: Embedder, onProgress?: (done: number, total: number) => void, analyzedProject?: MarkdownProjectAnalysis): Promise<IndexStats>;
|
package/dist/src/search/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
2
|
import { dirname, join } from 'node:path';
|
|
4
|
-
import {
|
|
3
|
+
import { analyzeMarkdownProject, } from '../project-analysis.js';
|
|
5
4
|
function hashContent(text) {
|
|
6
5
|
return createHash('sha256').update(text).digest('hex');
|
|
7
6
|
}
|
|
@@ -11,12 +10,14 @@ function hashContent(text) {
|
|
|
11
10
|
* O(sections × file size) — a 3.5 MB file holding 12k sections was re-read 12k
|
|
12
11
|
* times (~42 GB of string work) on every search.
|
|
13
12
|
*/
|
|
14
|
-
|
|
13
|
+
function loadFileLines(sections, projectRoot, project) {
|
|
15
14
|
const lines = new Map();
|
|
16
15
|
for (const { filePath } of sections) {
|
|
17
16
|
if (lines.has(filePath))
|
|
18
17
|
continue;
|
|
19
|
-
const content =
|
|
18
|
+
const content = project.filesByAbsolutePath.get(join(projectRoot, filePath))?.content;
|
|
19
|
+
if (content === undefined)
|
|
20
|
+
throw new Error(`Analyzed Markdown file not found: ${filePath}`);
|
|
20
21
|
lines.set(filePath, content.split('\n'));
|
|
21
22
|
}
|
|
22
23
|
return lines;
|
|
@@ -27,13 +28,14 @@ function sectionContent(section, lines) {
|
|
|
27
28
|
.slice(section.startLine - 1, section.endLine)
|
|
28
29
|
.join('\n');
|
|
29
30
|
}
|
|
30
|
-
export async function indexSections(latDir, db, embedder, onProgress) {
|
|
31
|
+
export async function indexSections(latDir, db, embedder, onProgress, analyzedProject) {
|
|
31
32
|
const projectRoot = dirname(latDir);
|
|
32
|
-
const
|
|
33
|
-
|
|
33
|
+
const project = analyzedProject ??
|
|
34
|
+
(await analyzeMarkdownProject(latDir, projectRoot, { executor: 'auto' }));
|
|
35
|
+
const flat = project.sections;
|
|
34
36
|
// Build current state: id -> { section, content, hash }
|
|
35
37
|
const current = new Map();
|
|
36
|
-
const lines =
|
|
38
|
+
const lines = loadFileLines(flat, projectRoot, project);
|
|
37
39
|
for (const s of flat) {
|
|
38
40
|
const text = sectionContent(s, lines);
|
|
39
41
|
current.set(s.id, { section: s, content: text, hash: hashContent(text) });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Section, SectionMatch } from '../lattice-model.js';
|
|
2
|
+
import { type CreateSearchEngine } from './embedder.js';
|
|
3
|
+
export type IndexedSearchResult = {
|
|
4
|
+
query: string;
|
|
5
|
+
matches: SectionMatch[];
|
|
6
|
+
};
|
|
7
|
+
export type IndexedSearchSession = {
|
|
8
|
+
search: (query: string, limit: number, threshold?: number) => Promise<IndexedSearchResult>;
|
|
9
|
+
close: () => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
/** Open one reusable database and embedder for a sequence of index queries. */
|
|
12
|
+
export declare function openIndexedSearchSession(latDir: string, sectionById: ReadonlyMap<string, Section>, options?: {
|
|
13
|
+
cacheDir?: string;
|
|
14
|
+
createSearchEngine?: CreateSearchEngine;
|
|
15
|
+
}): Promise<IndexedSearchSession>;
|
|
16
|
+
/** Query a finished index and resolve its ids from precomputed section data. */
|
|
17
|
+
export declare function searchIndexedSections(latDir: string, query: string, limit: number, sectionById: ReadonlyMap<string, Section>, options?: {
|
|
18
|
+
cacheDir?: string;
|
|
19
|
+
threshold?: number;
|
|
20
|
+
}): Promise<IndexedSearchResult>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { closeDb, ensureMeta, ensureSectionsSchema, getStoredModel, openDb, } from './db.js';
|
|
2
|
+
import { embedderForIndex } from './embedder.js';
|
|
3
|
+
import { searchSections } from './search.js';
|
|
4
|
+
/** Open one reusable database and embedder for a sequence of index queries. */
|
|
5
|
+
export async function openIndexedSearchSession(latDir, sectionById, options = {}) {
|
|
6
|
+
const db = openDb(latDir, options.cacheDir);
|
|
7
|
+
let closed = false;
|
|
8
|
+
const close = async () => {
|
|
9
|
+
if (closed)
|
|
10
|
+
return;
|
|
11
|
+
closed = true;
|
|
12
|
+
await closeDb(db);
|
|
13
|
+
};
|
|
14
|
+
try {
|
|
15
|
+
await ensureMeta(db);
|
|
16
|
+
const stored = await getStoredModel(db);
|
|
17
|
+
if (stored === null) {
|
|
18
|
+
return {
|
|
19
|
+
search: async (query) => {
|
|
20
|
+
if (closed)
|
|
21
|
+
throw new Error('Search session is closed');
|
|
22
|
+
return { query, matches: [] };
|
|
23
|
+
},
|
|
24
|
+
close,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const embedder = await embedderForIndex(stored, latDir, options.createSearchEngine);
|
|
28
|
+
await ensureSectionsSchema(db, embedder.dimensions);
|
|
29
|
+
return {
|
|
30
|
+
async search(query, limit, threshold) {
|
|
31
|
+
if (closed)
|
|
32
|
+
throw new Error('Search session is closed');
|
|
33
|
+
const results = await searchSections(db, query, embedder, limit, threshold);
|
|
34
|
+
return {
|
|
35
|
+
query,
|
|
36
|
+
matches: results.flatMap((result) => {
|
|
37
|
+
const section = sectionById.get(result.id.toLowerCase());
|
|
38
|
+
return section
|
|
39
|
+
? [
|
|
40
|
+
{
|
|
41
|
+
section,
|
|
42
|
+
reason: 'semantic match',
|
|
43
|
+
score: result.score,
|
|
44
|
+
},
|
|
45
|
+
]
|
|
46
|
+
: [];
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
close,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
await close();
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Query a finished index and resolve its ids from precomputed section data. */
|
|
59
|
+
export async function searchIndexedSections(latDir, query, limit, sectionById, options = {}) {
|
|
60
|
+
const session = await openIndexedSearchSession(latDir, sectionById, options);
|
|
61
|
+
try {
|
|
62
|
+
return await session.search(query, limit, options.threshold);
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
await session.close();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Client } from '@libsql/client';
|
|
2
2
|
import type { Embedder } from './embedder.js';
|
|
3
|
+
export declare const DEFAULT_SEARCH_LIMIT = 5;
|
|
4
|
+
export declare const DEFAULT_SEARCH_THRESHOLD = 0.35;
|
|
3
5
|
export type SearchResult = {
|
|
4
6
|
id: string;
|
|
5
7
|
file: string;
|
|
@@ -7,4 +9,4 @@ export type SearchResult = {
|
|
|
7
9
|
content: string;
|
|
8
10
|
score: number;
|
|
9
11
|
};
|
|
10
|
-
export declare function searchSections(db: Client, query: string, embedder: Embedder, limit?: number): Promise<SearchResult[]>;
|
|
12
|
+
export declare function searchSections(db: Client, query: string, embedder: Embedder, limit?: number, threshold?: number): Promise<SearchResult[]>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const DEFAULT_SEARCH_LIMIT = 5;
|
|
2
|
+
export const DEFAULT_SEARCH_THRESHOLD = 0.35;
|
|
3
|
+
export async function searchSections(db, query, embedder, limit = DEFAULT_SEARCH_LIMIT, threshold = DEFAULT_SEARCH_THRESHOLD) {
|
|
2
4
|
const [queryVec] = await embedder.embed([query]);
|
|
3
5
|
const vecJson = JSON.stringify(queryVec);
|
|
4
6
|
const rows = await db.execute({
|
|
@@ -9,7 +11,7 @@ export async function searchSections(db, query, embedder, limit = 5) {
|
|
|
9
11
|
ORDER BY score DESC`,
|
|
10
12
|
args: [vecJson, vecJson, limit],
|
|
11
13
|
});
|
|
12
|
-
|
|
14
|
+
const results = rows.rows.map((row) => {
|
|
13
15
|
const score = Number(row.score);
|
|
14
16
|
return {
|
|
15
17
|
id: row.id,
|
|
@@ -19,4 +21,5 @@ export async function searchSections(db, query, embedder, limit = 5) {
|
|
|
19
21
|
score: Number.isFinite(score) ? score : 0,
|
|
20
22
|
};
|
|
21
23
|
});
|
|
24
|
+
return results.filter((result) => result.score >= threshold);
|
|
22
25
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Source file extensions supported by Lat's parser and code-reference scan. */
|
|
2
|
+
export declare const SOURCE_FILE_EXTENSIONS: readonly [".c", ".dart", ".go", ".h", ".java", ".js", ".jsx", ".py", ".rs", ".ts", ".tsx"];
|
|
3
|
+
/** A source extension supported everywhere Lat accepts source files. */
|
|
4
|
+
export type SourceFileExtension = (typeof SOURCE_FILE_EXTENSIONS)[number];
|
|
5
|
+
export declare function isSourceFileExtension(extension: string): extension is SourceFileExtension;
|
|
6
|
+
export declare function sourceFileExtension(path: string): SourceFileExtension | null;
|
|
7
|
+
export declare function isSourceFilePath(path: string): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { extname } from 'node:path';
|
|
2
|
+
/** Source file extensions supported by Lat's parser and code-reference scan. */
|
|
3
|
+
export const SOURCE_FILE_EXTENSIONS = [
|
|
4
|
+
'.c',
|
|
5
|
+
'.dart',
|
|
6
|
+
'.go',
|
|
7
|
+
'.h',
|
|
8
|
+
'.java',
|
|
9
|
+
'.js',
|
|
10
|
+
'.jsx',
|
|
11
|
+
'.py',
|
|
12
|
+
'.rs',
|
|
13
|
+
'.ts',
|
|
14
|
+
'.tsx',
|
|
15
|
+
];
|
|
16
|
+
const sourceFileExtensionSet = new Set(SOURCE_FILE_EXTENSIONS);
|
|
17
|
+
export function isSourceFileExtension(extension) {
|
|
18
|
+
return sourceFileExtensionSet.has(extension);
|
|
19
|
+
}
|
|
20
|
+
export function sourceFileExtension(path) {
|
|
21
|
+
const extension = extname(path);
|
|
22
|
+
return isSourceFileExtension(extension) ? extension : null;
|
|
23
|
+
}
|
|
24
|
+
export function isSourceFilePath(path) {
|
|
25
|
+
return sourceFileExtension(path) !== null;
|
|
26
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Section } from './lattice.js';
|
|
1
|
+
import type { Section } from './lattice-model.js';
|
|
2
2
|
export type SourceSymbol = {
|
|
3
3
|
name: string;
|
|
4
4
|
kind: 'function' | 'class' | 'const' | 'type' | 'interface' | 'method' | 'variable';
|
|
@@ -7,16 +7,55 @@ export type SourceSymbol = {
|
|
|
7
7
|
endLine: number;
|
|
8
8
|
signature: string;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
export
|
|
10
|
+
export type SourceAnalysisCacheStatus = 'disabled' | 'hit' | 'miss';
|
|
11
|
+
export type SourceAnalysisTimings = {
|
|
12
|
+
readMs: number;
|
|
13
|
+
hashMs: number;
|
|
14
|
+
cacheReadMs: number;
|
|
15
|
+
cacheWriteMs: number;
|
|
16
|
+
parseMs: number;
|
|
17
|
+
cacheStatus: SourceAnalysisCacheStatus;
|
|
18
|
+
};
|
|
19
|
+
export type SourceFileAnalysis = {
|
|
20
|
+
path: string;
|
|
21
|
+
symbols: SourceSymbol[];
|
|
22
|
+
timings: SourceAnalysisTimings;
|
|
23
|
+
};
|
|
24
|
+
export type AnalyzeSourceSymbolsOptions = {
|
|
25
|
+
identity?: string;
|
|
26
|
+
cache?: boolean;
|
|
27
|
+
readMs?: number;
|
|
28
|
+
runtime?: SourceParserRuntime;
|
|
29
|
+
};
|
|
30
|
+
export type ResolveSourceSymbolOptions = {
|
|
31
|
+
latDir?: string;
|
|
32
|
+
cache?: boolean;
|
|
33
|
+
onFileAnalyzed?: (analysis: SourceFileAnalysis) => void;
|
|
34
|
+
runtime?: SourceParserRuntime;
|
|
35
|
+
};
|
|
12
36
|
export declare function parseSourceSymbols(filePath: string, content: string): Promise<SourceSymbol[]>;
|
|
37
|
+
type ResolvedSourceCacheEntry = {
|
|
38
|
+
symbols: SourceSymbol[];
|
|
39
|
+
analysis?: SourceFileAnalysis;
|
|
40
|
+
error?: string;
|
|
41
|
+
};
|
|
42
|
+
/** Request-scoped owner for in-flight and completed source parser work. */
|
|
43
|
+
export declare class SourceParserRuntime {
|
|
44
|
+
readonly analyses: Map<string, Promise<SourceFileAnalysis>>;
|
|
45
|
+
readonly symbols: Map<string, Promise<ResolvedSourceCacheEntry>>;
|
|
46
|
+
clear(): void;
|
|
47
|
+
}
|
|
48
|
+
/** Return the parser cache path for one project source file. */
|
|
49
|
+
export declare function sourceAnalysisCachePath(latDir: string, projectRoot: string, absolutePath: string): string;
|
|
50
|
+
/** Analyze source content through the shared versioned persistent cache. */
|
|
51
|
+
export declare function analyzeSourceSymbols(filePath: string, content: string, latDir: string, options?: AnalyzeSourceSymbolsOptions): Promise<SourceFileAnalysis>;
|
|
13
52
|
/** Clear the symbol cache. Call between top-level operations. */
|
|
14
53
|
export declare function clearSymbolCache(): void;
|
|
15
54
|
/**
|
|
16
55
|
* Check whether a source file path (relative to projectRoot) has a given symbol.
|
|
17
56
|
* Used by lat check to validate source code wiki links lazily.
|
|
18
57
|
*/
|
|
19
|
-
export declare function resolveSourceSymbol(filePath: string, symbolPath: string, projectRoot: string): Promise<{
|
|
58
|
+
export declare function resolveSourceSymbol(filePath: string, symbolPath: string, projectRoot: string, options?: ResolveSourceSymbolOptions): Promise<{
|
|
20
59
|
found: boolean;
|
|
21
60
|
symbols: SourceSymbol[];
|
|
22
61
|
error?: string;
|
|
@@ -25,3 +64,4 @@ export declare function resolveSourceSymbol(filePath: string, symbolPath: string
|
|
|
25
64
|
* Convert source symbols to Section objects for uniform handling.
|
|
26
65
|
*/
|
|
27
66
|
export declare function sourceSymbolsToSections(symbols: SourceSymbol[], filePath: string): Section[];
|
|
67
|
+
export {};
|