@plebeiantech/lat.md 0.12.3-fork.13 → 0.12.3-fork.15
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/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 +52 -12
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type Section, type SectionMatch } from '../lattice.js';
|
|
1
|
+
import { type Section, type SectionMatch } from '../lattice-model.js';
|
|
2
2
|
import type { CmdContext, CmdResult } from '../context.js';
|
|
3
|
+
import type { ResolvedExternalContent } from '../external-sources.js';
|
|
3
4
|
import { type ProvenanceNote } from './check-status.js';
|
|
4
5
|
export type CodeBackRef = {
|
|
5
6
|
file: string;
|
|
@@ -24,6 +25,7 @@ export type SectionFound = {
|
|
|
24
25
|
resolved: Section;
|
|
25
26
|
}[];
|
|
26
27
|
outgoingSourceRefs: SourceRef[];
|
|
28
|
+
outgoingExternalRefs: ResolvedExternalContent[];
|
|
27
29
|
incomingRefs: SectionMatch[];
|
|
28
30
|
codeRefs: CodeBackRef[];
|
|
29
31
|
};
|
package/dist/src/cli/section.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { extname, join, relative } from 'node:path';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { findSections, flattenSections, resolveRef, } from '../lattice-model.js';
|
|
4
|
+
import { MAX_SECTION_SUMMARY_LENGTH } from '../markdown-validation.js';
|
|
5
|
+
import { resolveSourceSymbol } from '../source-parser.js';
|
|
6
|
+
import { isSourceFileExtension } from '../source-formats.js';
|
|
7
|
+
import { formatNavHints, formatResultList, formatSectionId, } from '../format.js';
|
|
8
|
+
import { findRefs } from './refs.js';
|
|
9
|
+
import { commandProjectAnalysis, commandProjectSession, } from '../project-analysis.js';
|
|
7
10
|
import { provenanceNote, formatProvenanceNote, } from './check-status.js';
|
|
8
11
|
/**
|
|
9
12
|
* Look up a section by id, return its content, outgoing wiki link targets,
|
|
@@ -11,8 +14,8 @@ import { provenanceNote, formatProvenanceNote, } from './check-status.js';
|
|
|
11
14
|
*/
|
|
12
15
|
export async function getSection(ctx, query) {
|
|
13
16
|
query = query.replace(/^\[\[|\]\]$/g, '');
|
|
14
|
-
const
|
|
15
|
-
const matches = findSections(allSections, query);
|
|
17
|
+
const project = await commandProjectAnalysis(ctx);
|
|
18
|
+
const matches = findSections(project.allSections, query);
|
|
16
19
|
if (matches.length === 0) {
|
|
17
20
|
return { kind: 'no-match', suggestions: [] };
|
|
18
21
|
}
|
|
@@ -27,28 +30,41 @@ export async function getSection(ctx, query) {
|
|
|
27
30
|
const section = top.section;
|
|
28
31
|
// Read raw content between startLine and the end of the last descendant
|
|
29
32
|
const absPath = join(ctx.projectRoot, section.filePath);
|
|
30
|
-
const
|
|
33
|
+
const analyzedFile = project.filesByAbsolutePath.get(absPath);
|
|
34
|
+
if (!analyzedFile)
|
|
35
|
+
return { kind: 'no-match', suggestions: [] };
|
|
36
|
+
const fileContent = analyzedFile.content;
|
|
31
37
|
const lines = fileContent.split('\n');
|
|
32
38
|
const end = fullEndLine(section);
|
|
33
39
|
const content = lines.slice(section.startLine - 1, end).join('\n');
|
|
34
40
|
// Find outgoing wiki link targets within this section's content
|
|
35
|
-
const flat =
|
|
36
|
-
const sectionIds = new Set(
|
|
37
|
-
const fileIndex =
|
|
38
|
-
const slugIndex = buildSectionSlugIndex(allSections);
|
|
39
|
-
const sectionRefs = extractRefs(absPath, fileContent, ctx.projectRoot);
|
|
41
|
+
const flat = project.sections;
|
|
42
|
+
const sectionIds = new Set(project.sectionIds);
|
|
43
|
+
const { fileIndex, slugIndex } = project;
|
|
40
44
|
const sectionId = section.id.toLowerCase();
|
|
45
|
+
const subtreeSections = flattenSections([section]);
|
|
46
|
+
const subtreeSectionIds = new Set(subtreeSections.map((subtreeSection) => subtreeSection.id.toLowerCase()));
|
|
47
|
+
const sectionRefs = subtreeSections.flatMap((subtreeSection) => project.outgoingRefsBySection.get(subtreeSection.id.toLowerCase()) ?? []);
|
|
41
48
|
const outgoingRefs = [];
|
|
42
49
|
const outgoingSourceRefs = [];
|
|
50
|
+
const outgoingExternalRefs = [];
|
|
51
|
+
const external = await commandProjectSession(ctx).external();
|
|
43
52
|
const seen = new Set();
|
|
44
53
|
for (const ref of sectionRefs) {
|
|
45
|
-
if (ref.fromSection.toLowerCase()
|
|
54
|
+
if (!subtreeSectionIds.has(ref.fromSection.toLowerCase()))
|
|
55
|
+
continue;
|
|
56
|
+
if (external.parse(ref.target)) {
|
|
57
|
+
if (!seen.has(ref.target)) {
|
|
58
|
+
seen.add(ref.target);
|
|
59
|
+
outgoingExternalRefs.push(await external.resolve(ref.target));
|
|
60
|
+
}
|
|
46
61
|
continue;
|
|
62
|
+
}
|
|
47
63
|
// Detect source code references by file extension
|
|
48
64
|
const hashIdx = ref.target.indexOf('#');
|
|
49
65
|
const filePart = hashIdx === -1 ? ref.target : ref.target.slice(0, hashIdx);
|
|
50
66
|
const ext = extname(filePart);
|
|
51
|
-
if (
|
|
67
|
+
if (isSourceFileExtension(ext)) {
|
|
52
68
|
const targetLower = ref.target.toLowerCase();
|
|
53
69
|
if (!seen.has(targetLower)) {
|
|
54
70
|
seen.add(targetLower);
|
|
@@ -57,7 +73,7 @@ export async function getSection(ctx, query) {
|
|
|
57
73
|
let endLine = 0;
|
|
58
74
|
let snippet = '';
|
|
59
75
|
if (symbolPart) {
|
|
60
|
-
const { found, symbols } = await resolveSourceSymbol(filePart, symbolPart, ctx.projectRoot);
|
|
76
|
+
const { found, symbols } = await resolveSourceSymbol(filePart, symbolPart, ctx.projectRoot, commandProjectSession(ctx).sourceSymbolOptions());
|
|
61
77
|
if (found) {
|
|
62
78
|
const parts = symbolPart.split('#');
|
|
63
79
|
const sym = symbols.find((s) => parts.length === 1
|
|
@@ -101,31 +117,24 @@ export async function getSection(ctx, query) {
|
|
|
101
117
|
}
|
|
102
118
|
// Find incoming references: other sections that link to this one
|
|
103
119
|
const incomingRefs = [];
|
|
104
|
-
const files = await listLatticeFiles(ctx.latDir);
|
|
105
120
|
const incomingSections = new Set();
|
|
106
|
-
for (const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
}
|
|
121
|
+
for (const ref of project.incomingRefsBySection.get(sectionId) ?? []) {
|
|
122
|
+
if (ref.fromSection.toLowerCase() === sectionId)
|
|
123
|
+
continue;
|
|
124
|
+
if (!incomingSections.has(ref.fromSection.toLowerCase())) {
|
|
125
|
+
incomingSections.add(ref.fromSection.toLowerCase());
|
|
126
|
+
const fromSection = project.sectionById.get(ref.fromSection.toLowerCase());
|
|
127
|
+
if (fromSection) {
|
|
128
|
+
incomingRefs.push({ section: fromSection, reason: 'wiki link' });
|
|
120
129
|
}
|
|
121
130
|
}
|
|
122
131
|
}
|
|
123
132
|
// Find code back-references: @lat: comments pointing to this section
|
|
124
133
|
const codeRefs = [];
|
|
125
|
-
const { refs: scannedRefs } = await
|
|
134
|
+
const { refs: scannedRefs } = await commandProjectSession(ctx).codeRefs();
|
|
126
135
|
for (const ref of scannedRefs) {
|
|
127
136
|
const { resolved: codeResolved } = resolveRef(ref.target, sectionIds, fileIndex, slugIndex);
|
|
128
|
-
if (codeResolved.toLowerCase()
|
|
137
|
+
if (subtreeSectionIds.has(codeResolved.toLowerCase())) {
|
|
129
138
|
const absFile = join(ctx.projectRoot, ref.file);
|
|
130
139
|
let snippet = '';
|
|
131
140
|
try {
|
|
@@ -148,6 +157,7 @@ export async function getSection(ctx, query) {
|
|
|
148
157
|
status: provenanceNote(fileContent),
|
|
149
158
|
outgoingRefs,
|
|
150
159
|
outgoingSourceRefs,
|
|
160
|
+
outgoingExternalRefs,
|
|
151
161
|
incomingRefs,
|
|
152
162
|
codeRefs,
|
|
153
163
|
};
|
|
@@ -160,12 +170,23 @@ function fullEndLine(section) {
|
|
|
160
170
|
function truncate(s, max) {
|
|
161
171
|
return s.length > max ? s.slice(0, max) + '...' : s;
|
|
162
172
|
}
|
|
173
|
+
const SECTION_SUMMARY_SAFETY_LIMIT = MAX_SECTION_SUMMARY_LENGTH + 50;
|
|
174
|
+
function sectionSummary(section) {
|
|
175
|
+
return truncate(section.firstParagraph, SECTION_SUMMARY_SAFETY_LIMIT);
|
|
176
|
+
}
|
|
177
|
+
function markdownInlineCode(value) {
|
|
178
|
+
const content = value || ' ';
|
|
179
|
+
const longestBacktickRun = Math.max(0, ...(content.match(/`+/g) ?? []).map((run) => run.length));
|
|
180
|
+
const delimiter = '`'.repeat(longestBacktickRun + 1);
|
|
181
|
+
const padded = content.startsWith('`') || content.endsWith('`') ? ` ${content} ` : content;
|
|
182
|
+
return `${delimiter}${padded}${delimiter}`;
|
|
183
|
+
}
|
|
163
184
|
/**
|
|
164
185
|
* Format a successful section result with styling.
|
|
165
186
|
*/
|
|
166
187
|
export function formatSectionOutput(ctx, result) {
|
|
167
188
|
const s = ctx.styler;
|
|
168
|
-
const { section, content, status, outgoingRefs, outgoingSourceRefs, incomingRefs, codeRefs, } = result;
|
|
189
|
+
const { section, content, status, outgoingRefs, outgoingSourceRefs, outgoingExternalRefs, incomingRefs, codeRefs, } = result;
|
|
169
190
|
const relPath = relative(process.cwd(), join(ctx.projectRoot, section.filePath));
|
|
170
191
|
const loc = `${s.cyan(relPath)}${s.dim(`:${section.startLine}-${section.endLine}`)}`;
|
|
171
192
|
const quoted = content
|
|
@@ -180,11 +201,13 @@ export function formatSectionOutput(ctx, result) {
|
|
|
180
201
|
if (status)
|
|
181
202
|
parts.push(formatProvenanceNote(status, s));
|
|
182
203
|
parts.push('', quoted);
|
|
183
|
-
if (outgoingRefs.length > 0 ||
|
|
204
|
+
if (outgoingRefs.length > 0 ||
|
|
205
|
+
outgoingSourceRefs.length > 0 ||
|
|
206
|
+
outgoingExternalRefs.length > 0) {
|
|
184
207
|
parts.push('', '## This section references:', '');
|
|
185
208
|
for (const ref of outgoingRefs) {
|
|
186
209
|
const body = ref.resolved.firstParagraph
|
|
187
|
-
? ` ${s.dim('—')} ${
|
|
210
|
+
? ` ${s.dim('—')} ${sectionSummary(ref.resolved)}`
|
|
188
211
|
: '';
|
|
189
212
|
parts.push(`${s.dim('*')} [[${formatSectionId(ref.resolved.id, s)}]]${body}`);
|
|
190
213
|
}
|
|
@@ -198,16 +221,22 @@ export function formatSectionOutput(ctx, result) {
|
|
|
198
221
|
if (ref.snippet) {
|
|
199
222
|
const snippetLines = ref.snippet.split('\n');
|
|
200
223
|
for (const line of snippetLines) {
|
|
201
|
-
parts.push(` ${s.dim('|')} ${line}`);
|
|
224
|
+
parts.push(` ${s.dim('|')} ${markdownInlineCode(line)}`);
|
|
202
225
|
}
|
|
203
226
|
}
|
|
204
227
|
}
|
|
228
|
+
for (const ref of outgoingExternalRefs) {
|
|
229
|
+
parts.push(`${s.dim('*')} [[${s.cyan(ref.target.identity)}]]${s.dim(` (${ref.target.repositoryPath}:${ref.startLine}-${ref.endLine}, ${ref.provider})`)}`);
|
|
230
|
+
for (const line of ref.content.split('\n').slice(0, 5)) {
|
|
231
|
+
parts.push(` ${s.dim('|')} ${ref.kind === 'source' ? markdownInlineCode(line) : line}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
205
234
|
}
|
|
206
235
|
if (incomingRefs.length > 0) {
|
|
207
236
|
parts.push('', '## Referenced by:', '');
|
|
208
237
|
for (const ref of incomingRefs) {
|
|
209
238
|
const body = ref.section.firstParagraph
|
|
210
|
-
? ` ${s.dim('—')} ${
|
|
239
|
+
? ` ${s.dim('—')} ${sectionSummary(ref.section)}`
|
|
211
240
|
: '';
|
|
212
241
|
parts.push(`${s.dim('*')} [[${formatSectionId(ref.section.id, s)}]]${body}`);
|
|
213
242
|
}
|
|
@@ -220,7 +249,7 @@ export function formatSectionOutput(ctx, result) {
|
|
|
220
249
|
if (ref.snippet) {
|
|
221
250
|
const snippetLines = ref.snippet.split('\n');
|
|
222
251
|
for (const line of snippetLines) {
|
|
223
|
-
parts.push(` ${s.dim('|')} ${line}`);
|
|
252
|
+
parts.push(` ${s.dim('|')} ${markdownInlineCode(line)}`);
|
|
224
253
|
}
|
|
225
254
|
}
|
|
226
255
|
}
|
|
@@ -229,6 +258,53 @@ export function formatSectionOutput(ctx, result) {
|
|
|
229
258
|
return parts.join('\n');
|
|
230
259
|
}
|
|
231
260
|
export async function sectionCommand(ctx, query) {
|
|
261
|
+
const external = await commandProjectSession(ctx).external();
|
|
262
|
+
let externalTarget = null;
|
|
263
|
+
try {
|
|
264
|
+
externalTarget = external.parse(query);
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
return { output: ctx.styler.red(error.message), isError: true };
|
|
268
|
+
}
|
|
269
|
+
if (externalTarget) {
|
|
270
|
+
try {
|
|
271
|
+
const resolved = await external.resolve(query);
|
|
272
|
+
const backlinks = await findRefs(ctx, resolved.target.identity, 'md+code');
|
|
273
|
+
const location = `${resolved.target.handle}:${resolved.target.authoredPath}:${resolved.startLine}-${resolved.endLine}`;
|
|
274
|
+
const quoted = resolved.content
|
|
275
|
+
.split('\n')
|
|
276
|
+
.map((line) => (line ? `> ${line}` : '>'))
|
|
277
|
+
.join('\n');
|
|
278
|
+
const warnings = resolved.source.localError
|
|
279
|
+
? `\n\n${ctx.styler.yellow(`Warning: ${resolved.source.localError}; using ${resolved.provider}`)}`
|
|
280
|
+
: '';
|
|
281
|
+
const parts = [
|
|
282
|
+
`${ctx.styler.bold(`[[${resolved.target.identity}]]`)} (${ctx.styler.cyan(location)})`,
|
|
283
|
+
ctx.styler.dim(`${resolved.source.repo} @ ${resolved.source.commit} via ${resolved.provider}`),
|
|
284
|
+
'',
|
|
285
|
+
quoted,
|
|
286
|
+
];
|
|
287
|
+
if (backlinks.kind === 'found' && backlinks.mdRefs.length > 0) {
|
|
288
|
+
parts.push(formatResultList(ctx, `Referenced by Markdown:`, backlinks.mdRefs));
|
|
289
|
+
}
|
|
290
|
+
if (backlinks.kind === 'found' && backlinks.codeRefs.length > 0) {
|
|
291
|
+
parts.push('', '## Referenced by code:', '', ...backlinks.codeRefs.map((value) => `${ctx.styler.dim('*')} ${value}`));
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
output: parts.join('\n') + warnings + formatNavHints(ctx),
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
return {
|
|
299
|
+
output: ctx.styler.red(error.message),
|
|
300
|
+
isError: true,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const unknownExternal = external.unknownTargetMessage(query);
|
|
305
|
+
if (unknownExternal) {
|
|
306
|
+
return { output: ctx.styler.red(unknownExternal), isError: true };
|
|
307
|
+
}
|
|
232
308
|
const result = await getSection(ctx, query);
|
|
233
309
|
if (result.kind === 'no-match') {
|
|
234
310
|
const s = ctx.styler;
|
package/dist/src/code-refs.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { Profiler } from './profiler.js';
|
|
2
|
+
/** Walk supported source files for code-ref scanning. Uses walkEntries for
|
|
3
|
+
* .gitignore support, then additionally skips lat.md/, .claude/, generated
|
|
4
|
+
* UI output, and sub-projects. */
|
|
3
5
|
export declare function walkFiles(dir: string): Promise<string[]>;
|
|
4
6
|
export declare const LAT_REF_RE: RegExp;
|
|
5
7
|
export type CodeRef = {
|
|
@@ -9,9 +11,19 @@ export type CodeRef = {
|
|
|
9
11
|
};
|
|
10
12
|
export type ScanResult = {
|
|
11
13
|
refs: CodeRef[];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
};
|
|
15
|
+
export type CodeReferenceDiscovery = {
|
|
16
|
+
scan: () => Promise<ScanResult>;
|
|
17
|
+
listSourceFiles: () => Promise<string[]>;
|
|
14
18
|
};
|
|
15
19
|
/** Check whether ripgrep (`rg`) is available on PATH. */
|
|
16
20
|
export declare function hasRipgrep(): Promise<boolean>;
|
|
17
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Create a lazy project-scoped discovery API. Code-reference scanning and
|
|
23
|
+
* source-file inventory are separate operations, but share ripgrep exclusion
|
|
24
|
+
* discovery and coalesce fallback file walking when both are requested.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createCodeReferenceDiscovery(projectRoot: string, profile?: Pick<Profiler, 'time'>): CodeReferenceDiscovery;
|
|
27
|
+
export declare function scanCodeRefs(projectRoot: string, profile?: Pick<Profiler, 'time'>): Promise<ScanResult>;
|
|
28
|
+
/** Discover the source files that may contain code references. */
|
|
29
|
+
export declare function discoverSourceFiles(projectRoot: string, profile?: Pick<Profiler, 'time'>): Promise<string[]>;
|