@plebeiantech/lat.md 0.12.3-fork.17 → 0.12.3-fork.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.md +1 -1
  2. package/dist/src/cli/agent-invocation.d.ts +6 -0
  3. package/dist/src/cli/agent-invocation.js +23 -0
  4. package/dist/src/cli/fork-instructions.js +1 -1
  5. package/dist/src/cli/fork-scaffold.js +2 -2
  6. package/dist/src/cli/graph.d.ts +1 -1
  7. package/dist/src/cli/hook.js +11 -11
  8. package/dist/src/cli/index.js +41 -59
  9. package/dist/src/cli/init-preferences.js +5 -4
  10. package/dist/src/cli/init.d.ts +1 -1
  11. package/dist/src/cli/init.js +54 -45
  12. package/dist/src/cli/reindex.d.ts +1 -1
  13. package/dist/src/cli/reindex.js +2 -2
  14. package/dist/src/cli/search.d.ts +4 -4
  15. package/dist/src/cli/search.js +41 -28
  16. package/dist/src/cli/ui-build-server.d.ts +1 -1
  17. package/dist/src/cli/ui-build.d.ts +1 -1
  18. package/dist/src/cli/ui.d.ts +1 -1
  19. package/dist/src/fork/antigravity-hook.js +6 -6
  20. package/dist/src/fork/antigravity-init.d.ts +2 -2
  21. package/dist/src/fork/antigravity-init.js +2 -2
  22. package/dist/src/graph-export.js +7 -7
  23. package/dist/src/knowledge/index.js +2 -2
  24. package/dist/src/mcp/server.js +8 -8
  25. package/dist/src/search/cache.d.ts +1 -1
  26. package/dist/src/search/cache.js +40 -7
  27. package/dist/src/search/chunks.d.ts +2 -2
  28. package/dist/src/search/db.d.ts +5 -4
  29. package/dist/src/search/db.js +36 -40
  30. package/dist/src/search/embedder.js +1 -1
  31. package/dist/src/search/index.d.ts +1 -1
  32. package/dist/src/search/index.js +2 -2
  33. package/dist/src/search/lock.d.ts +4 -1
  34. package/dist/src/search/lock.js +30 -8
  35. package/dist/src/search/query.d.ts +5 -2
  36. package/dist/src/search/query.js +55 -38
  37. package/dist/src/search/search.d.ts +3 -1
  38. package/dist/src/search/search.js +21 -12
  39. package/dist/src/search/types.d.ts +2 -18
  40. package/dist/src/view/client/assets/{GraphView-BWlRdQM4.js → GraphView-Dij8mAA_.js} +1 -1
  41. package/dist/src/view/client/assets/{MarkdownEditor-MW-Ck1O0.js → MarkdownEditor-88Wbt0M1.js} +1 -1
  42. package/dist/src/view/client/assets/{abnfDiagram-VCTEODGH-Bn3RshMV.js → abnfDiagram-VCTEODGH-y0DlYa8E.js} +1 -1
  43. package/dist/src/view/client/assets/{arc-En9tdFQF.js → arc-FlMu8dnO.js} +1 -1
  44. package/dist/src/view/client/assets/{architectureDiagram-5GKGNRK7-B-9J1VAM.js → architectureDiagram-5GKGNRK7-DA_uWZW1.js} +1 -1
  45. package/dist/src/view/client/assets/{blockDiagram-I7D4REHJ-QlznwalP.js → blockDiagram-I7D4REHJ-BHQ5LU85.js} +1 -1
  46. package/dist/src/view/client/assets/{c4Diagram-7LVT6UL2-Bp2y8B4_.js → c4Diagram-7LVT6UL2-BRucKCt2.js} +1 -1
  47. package/dist/src/view/client/assets/channel-BgDNA_Ay.js +1 -0
  48. package/dist/src/view/client/assets/{chunk-2Q5K7J3B-CnBKL-lm.js → chunk-2Q5K7J3B-BJPcFivt.js} +1 -1
  49. package/dist/src/view/client/assets/{chunk-5VM5RSS4-LLYMi_n6.js → chunk-5VM5RSS4-v2q99bGz.js} +1 -1
  50. package/dist/src/view/client/assets/{chunk-F27PBJKO-VIeO7VF0.js → chunk-F27PBJKO-CcHOuJCs.js} +1 -1
  51. package/dist/src/view/client/assets/{chunk-IMKFNOWR-D5i67DVD.js → chunk-IMKFNOWR-DNxYuJNq.js} +1 -1
  52. package/dist/src/view/client/assets/{chunk-JWPE2WC7-D4qAtoL3.js → chunk-JWPE2WC7-C0eHKvLW.js} +1 -1
  53. package/dist/src/view/client/assets/{chunk-POPQ4Y6H-BMzOyiW_.js → chunk-POPQ4Y6H-57CWp2Ve.js} +1 -1
  54. package/dist/src/view/client/assets/{chunk-SVP7TREG-DWy5nbfp.js → chunk-SVP7TREG-BqcoxIJw.js} +1 -1
  55. package/dist/src/view/client/assets/{chunk-TICWLB2K-CVqCANFB.js → chunk-TICWLB2K-DRUJR5zH.js} +1 -1
  56. package/dist/src/view/client/assets/{chunk-XXDRQBXY-Bp23h6Tf.js → chunk-XXDRQBXY-Dez0oRoM.js} +1 -1
  57. package/dist/src/view/client/assets/classDiagram-ZZMXUADV-CFZ_Sgh5.js +1 -0
  58. package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-CFZ_Sgh5.js +1 -0
  59. package/dist/src/view/client/assets/{cose-bilkent-JH36ORCC-BCw7fCC2.js → cose-bilkent-JH36ORCC-BHtud6Hg.js} +1 -1
  60. package/dist/src/view/client/assets/{cynefin-OW5HDTMX--lYN4N9m.js → cynefin-OW5HDTMX-BjBW8VGk.js} +1 -1
  61. package/dist/src/view/client/assets/{cynefinDiagram-5FMLGOSQ-9sK5EV7v.js → cynefinDiagram-5FMLGOSQ-DwGuD7oF.js} +1 -1
  62. package/dist/src/view/client/assets/{dagre-GXQ25YYZ-CoMdEFCq.js → dagre-GXQ25YYZ-C5zSlGK9.js} +1 -1
  63. package/dist/src/view/client/assets/{diagram-S7CK7UJ4-D13dyWdd.js → diagram-S7CK7UJ4-C_NhA3bj.js} +1 -1
  64. package/dist/src/view/client/assets/{diagram-UQ7AKVKN-PdwLPPPA.js → diagram-UQ7AKVKN-az7QPYNb.js} +1 -1
  65. package/dist/src/view/client/assets/{diagram-VSXAHHWV-CtWWa_A7.js → diagram-VSXAHHWV-BRvDuM8_.js} +1 -1
  66. package/dist/src/view/client/assets/{diagram-VX7I27RA-BeCYcSU-.js → diagram-VX7I27RA-BWLgF6S-.js} +1 -1
  67. package/dist/src/view/client/assets/{diagram-Z3DM3KII-DiWabOBM.js → diagram-Z3DM3KII-DV3d6mL5.js} +1 -1
  68. package/dist/src/view/client/assets/{ebnfDiagram-PWID7BFC-CZQ3MD_K.js → ebnfDiagram-PWID7BFC-yUXrEAvK.js} +1 -1
  69. package/dist/src/view/client/assets/{erDiagram-RLTQ6QDP-B1AhXIrP.js → erDiagram-RLTQ6QDP-D35FN1Pt.js} +1 -1
  70. package/dist/src/view/client/assets/{flowDiagram-HODETNUW-Bhr0JM6P.js → flowDiagram-HODETNUW-BciZqsjT.js} +1 -1
  71. package/dist/src/view/client/assets/{ganttDiagram-EL5Y4UJY-CbP8iAkg.js → ganttDiagram-EL5Y4UJY-BysPGgXS.js} +1 -1
  72. package/dist/src/view/client/assets/{gitGraphDiagram-WWUBYQGX-B9uuGdLF.js → gitGraphDiagram-WWUBYQGX-C3DdJ5xG.js} +1 -1
  73. package/dist/src/view/client/assets/index-CJokoRSp.js +13 -0
  74. package/dist/src/view/client/assets/{infoDiagram-27XIBGKW-BrfwQ_Cq.js → infoDiagram-27XIBGKW-D3HZrDRb.js} +1 -1
  75. package/dist/src/view/client/assets/{ishikawaDiagram-5VMMS53U-CHtJ36re.js → ishikawaDiagram-5VMMS53U-BXyVIXTU.js} +1 -1
  76. package/dist/src/view/client/assets/{journeyDiagram-3NMN7TZE-BChcgX1s.js → journeyDiagram-3NMN7TZE-D4-1NxVU.js} +1 -1
  77. package/dist/src/view/client/assets/{kanban-definition-UXKFOSKX-BnwFsKiB.js → kanban-definition-UXKFOSKX-4Gu_5yBA.js} +1 -1
  78. package/dist/src/view/client/assets/{layout-Dnd0pLdb.js → layout-Jf1K3TMM.js} +1 -1
  79. package/dist/src/view/client/assets/{linear-CFhW2ozn.js → linear-DWfwzUT_.js} +1 -1
  80. package/dist/src/view/client/assets/{mermaid.core--OP6lXtW.js → mermaid.core-DMx_DAl8.js} +5 -5
  81. package/dist/src/view/client/assets/{mindmap-definition-YA3MSWOX-D51y2zbm.js → mindmap-definition-YA3MSWOX-8pxY_RWi.js} +1 -1
  82. package/dist/src/view/client/assets/{pegDiagram-XKGWAZYB--zyQJDvI.js → pegDiagram-XKGWAZYB-DNAw_O5t.js} +1 -1
  83. package/dist/src/view/client/assets/{pieDiagram-E7YTZNPT-Cj8mvpJy.js → pieDiagram-E7YTZNPT-uuvRCDkC.js} +1 -1
  84. package/dist/src/view/client/assets/{quadrantDiagram-AXDQQJYC-qvhJrnBf.js → quadrantDiagram-AXDQQJYC-BER2O4Aq.js} +1 -1
  85. package/dist/src/view/client/assets/{railroadDiagram-O6MQD6OU-CtWvxpSo.js → railroadDiagram-O6MQD6OU-CxEsJ_0n.js} +1 -1
  86. package/dist/src/view/client/assets/{requirementDiagram-BXWQKSXE-CBxen_KG.js → requirementDiagram-BXWQKSXE-yS9rspca.js} +1 -1
  87. package/dist/src/view/client/assets/{sankeyDiagram-P5KCCOFB-B_fUkmfc.js → sankeyDiagram-P5KCCOFB-Bqt70a2j.js} +1 -1
  88. package/dist/src/view/client/assets/{sequenceDiagram-WJ2MYXX4-Dclv4p68.js → sequenceDiagram-WJ2MYXX4-BvOOEJNr.js} +1 -1
  89. package/dist/src/view/client/assets/{sizeCapture-INFHLROL-GfG0sMTZ.js → sizeCapture-INFHLROL-CvO_Pjjo.js} +1 -1
  90. package/dist/src/view/client/assets/{stateDiagram-D77RDMKH-YQWPnzxU.js → stateDiagram-D77RDMKH-KLmVOZkq.js} +1 -1
  91. package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-KCS8Mdzu.js +1 -0
  92. package/dist/src/view/client/assets/{swimlanes-42K2YHIH-5yiCveVS.js → swimlanes-42K2YHIH-DC1r4_sq.js} +1 -1
  93. package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-B2TcAwis.js +8 -0
  94. package/dist/src/view/client/assets/{timeline-definition-24CTP7MA-BvAbB5Zs.js → timeline-definition-24CTP7MA-ChXLOuBL.js} +1 -1
  95. package/dist/src/view/client/assets/{vennDiagram-4TSXK5OY-guC-r60n.js → vennDiagram-4TSXK5OY-D9_h25-Y.js} +1 -1
  96. package/dist/src/view/client/assets/{wardleyDiagram-VM6X3IG4-C0yXcU2x.js → wardleyDiagram-VM6X3IG4-CsQJGGW0.js} +1 -1
  97. package/dist/src/view/client/assets/{xychartDiagram-S5SC5T6Z-RPmkPNfK.js → xychartDiagram-S5SC5T6Z-DGMuPMlm.js} +1 -1
  98. package/dist/src/view/client/index.html +1 -1
  99. package/dist/src/view/diagnostics.d.ts +2 -2
  100. package/dist/src/view/diagnostics.js +5 -5
  101. package/dist/src/view/external-document-tree.js +1 -1
  102. package/dist/src/view/git-diff.js +1 -1
  103. package/dist/src/view/git.js +1 -1
  104. package/dist/src/view/graph.d.ts +2 -2
  105. package/dist/src/view/graph.js +2 -2
  106. package/dist/src/view/markdown.js +1 -1
  107. package/dist/src/view/preindexed-search.d.ts +1 -1
  108. package/dist/src/view/protocol.d.ts +2 -18
  109. package/dist/src/view/publication.d.ts +2 -0
  110. package/dist/src/view/publication.js +78 -0
  111. package/dist/src/view/references.d.ts +3 -3
  112. package/dist/src/view/references.js +3 -3
  113. package/dist/src/view/repository.d.ts +6 -6
  114. package/dist/src/view/repository.js +28 -14
  115. package/dist/src/view/request-security.d.ts +5 -0
  116. package/dist/src/view/request-security.js +46 -0
  117. package/dist/src/view/search-result.d.ts +1 -1
  118. package/dist/src/view/search-result.js +1 -1
  119. package/dist/src/view/search.d.ts +1 -1
  120. package/dist/src/view/server-build.d.ts +2 -2
  121. package/dist/src/view/server-build.js +2 -2
  122. package/dist/src/view/server-deployment.d.ts +1 -2
  123. package/dist/src/view/server-deployment.js +6 -46
  124. package/dist/src/view/server-index-worker.d.ts +1 -1
  125. package/dist/src/view/server.d.ts +1 -1
  126. package/dist/src/view/server.js +13 -3
  127. package/dist/src/view/source-target.js +2 -2
  128. package/dist/src/view/static-build.d.ts +1 -1
  129. package/dist/src/view/static-build.js +49 -17
  130. package/dist/src/view/store.d.ts +4 -2
  131. package/dist/src/view/store.js +31 -19
  132. package/dist/src/view/table-of-contents.d.ts +1 -1
  133. package/dist/src/view/table-of-contents.js +1 -1
  134. package/dist/src/view/vercel-server-build.d.ts +1 -1
  135. package/package.json +19 -29
  136. package/templates/AGENTS.md +2 -2
  137. package/templates/cursor-rules.md +2 -2
  138. package/templates/opencode-plugin.ts +9 -9
  139. package/templates/pi-extension.ts +11 -11
  140. package/templates/skill/SKILL.md +2 -1
  141. package/dist/src/cli/check-context.d.ts +0 -56
  142. package/dist/src/cli/check-context.js +0 -215
  143. package/dist/src/cli/check-coverage.d.ts +0 -2
  144. package/dist/src/cli/check-coverage.js +0 -75
  145. package/dist/src/cli/check-frontmatter.d.ts +0 -12
  146. package/dist/src/cli/check-frontmatter.js +0 -44
  147. package/dist/src/cli/check-mode.d.ts +0 -21
  148. package/dist/src/cli/check-mode.js +0 -394
  149. package/dist/src/cli/check-status.d.ts +0 -74
  150. package/dist/src/cli/check-status.js +0 -217
  151. package/dist/src/cli/check.d.ts +0 -52
  152. package/dist/src/cli/check.js +0 -834
  153. package/dist/src/cli/context.d.ts +0 -11
  154. package/dist/src/cli/context.js +0 -58
  155. package/dist/src/cli/expand.d.ts +0 -7
  156. package/dist/src/cli/expand.js +0 -141
  157. package/dist/src/cli/external.d.ts +0 -11
  158. package/dist/src/cli/external.js +0 -185
  159. package/dist/src/cli/gen-index.d.ts +0 -45
  160. package/dist/src/cli/gen-index.js +0 -235
  161. package/dist/src/cli/link-scheme.d.ts +0 -54
  162. package/dist/src/cli/link-scheme.js +0 -101
  163. package/dist/src/cli/locate.d.ts +0 -2
  164. package/dist/src/cli/locate.js +0 -18
  165. package/dist/src/cli/refs.d.ts +0 -23
  166. package/dist/src/cli/refs.js +0 -274
  167. package/dist/src/cli/section.d.ts +0 -45
  168. package/dist/src/cli/section.js +0 -328
  169. package/dist/src/cli/select-menu.d.ts +0 -13
  170. package/dist/src/cli/select-menu.js +0 -100
  171. package/dist/src/code-refs.d.ts +0 -29
  172. package/dist/src/code-refs.js +0 -479
  173. package/dist/src/config.d.ts +0 -29
  174. package/dist/src/config.js +0 -83
  175. package/dist/src/context.d.ts +0 -26
  176. package/dist/src/context.js +0 -11
  177. package/dist/src/document-formats.d.ts +0 -7
  178. package/dist/src/document-formats.js +0 -39
  179. package/dist/src/extensions/alert-marker.d.ts +0 -25
  180. package/dist/src/extensions/alert-marker.js +0 -55
  181. package/dist/src/extensions/wiki-link/from-markdown.d.ts +0 -5
  182. package/dist/src/extensions/wiki-link/from-markdown.js +0 -34
  183. package/dist/src/extensions/wiki-link/index.d.ts +0 -4
  184. package/dist/src/extensions/wiki-link/index.js +0 -3
  185. package/dist/src/extensions/wiki-link/syntax.d.ts +0 -14
  186. package/dist/src/extensions/wiki-link/syntax.js +0 -121
  187. package/dist/src/extensions/wiki-link/to-markdown.d.ts +0 -5
  188. package/dist/src/extensions/wiki-link/to-markdown.js +0 -28
  189. package/dist/src/extensions/wiki-link/types.d.ts +0 -34
  190. package/dist/src/extensions/wiki-link/types.js +0 -1
  191. package/dist/src/external-documents.d.ts +0 -56
  192. package/dist/src/external-documents.js +0 -404
  193. package/dist/src/external-sources.d.ts +0 -136
  194. package/dist/src/external-sources.js +0 -1098
  195. package/dist/src/fork/frontmatter-fields.d.ts +0 -36
  196. package/dist/src/fork/frontmatter-fields.js +0 -23
  197. package/dist/src/format.d.ts +0 -16
  198. package/dist/src/format.js +0 -76
  199. package/dist/src/init-version.d.ts +0 -10
  200. package/dist/src/init-version.js +0 -49
  201. package/dist/src/lattice-model.d.ts +0 -84
  202. package/dist/src/lattice-model.js +0 -467
  203. package/dist/src/lattice.d.ts +0 -14
  204. package/dist/src/lattice.js +0 -353
  205. package/dist/src/markdown-analysis-cache.d.ts +0 -20
  206. package/dist/src/markdown-analysis-cache.js +0 -139
  207. package/dist/src/markdown-analysis-worker.d.ts +0 -16
  208. package/dist/src/markdown-analysis-worker.js +0 -33
  209. package/dist/src/markdown-analysis.d.ts +0 -61
  210. package/dist/src/markdown-analysis.js +0 -169
  211. package/dist/src/markdown-analyzer-loader.d.ts +0 -4
  212. package/dist/src/markdown-analyzer-loader.js +0 -13
  213. package/dist/src/markdown-validation.d.ts +0 -25
  214. package/dist/src/markdown-validation.js +0 -104
  215. package/dist/src/parser-cache.d.ts +0 -17
  216. package/dist/src/parser-cache.js +0 -65
  217. package/dist/src/parser-import.d.ts +0 -8
  218. package/dist/src/parser-import.js +0 -1
  219. package/dist/src/parser.d.ts +0 -3
  220. package/dist/src/parser.js +0 -93
  221. package/dist/src/path.d.ts +0 -2
  222. package/dist/src/path.js +0 -4
  223. package/dist/src/profiler.d.ts +0 -16
  224. package/dist/src/profiler.js +0 -81
  225. package/dist/src/project-analysis.d.ts +0 -59
  226. package/dist/src/project-analysis.js +0 -233
  227. package/dist/src/project-discovery.d.ts +0 -6
  228. package/dist/src/project-discovery.js +0 -30
  229. package/dist/src/repository-path.d.ts +0 -11
  230. package/dist/src/repository-path.js +0 -52
  231. package/dist/src/source-formats.d.ts +0 -7
  232. package/dist/src/source-formats.js +0 -30
  233. package/dist/src/source-parser.d.ts +0 -67
  234. package/dist/src/source-parser.js +0 -1749
  235. package/dist/src/untrusted.d.ts +0 -18
  236. package/dist/src/untrusted.js +0 -93
  237. package/dist/src/view/client/assets/channel-uy0fFvcW.js +0 -1
  238. package/dist/src/view/client/assets/classDiagram-ZZMXUADV-DbSEqjA5.js +0 -1
  239. package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-DbSEqjA5.js +0 -1
  240. package/dist/src/view/client/assets/index-nBmbYfun.js +0 -13
  241. package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-gUj6Hzgl.js +0 -1
  242. package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-DR7JhrxL.js +0 -8
  243. package/dist/src/walk.d.ts +0 -20
  244. package/dist/src/walk.js +0 -121
@@ -1,59 +0,0 @@
1
- import { type Ref, type Section, type SectionSlugIndex } from './lattice-model.js';
2
- import type { MarkdownFileAnalysis } from './markdown-analysis.js';
3
- import { type ScanResult } from './code-refs.js';
4
- import { type ResolveSourceSymbolOptions } from './source-parser.js';
5
- import { type ExternalResolver } from './external-sources.js';
6
- import type { ParserImportObserver } from './parser-import.js';
7
- export type MarkdownAnalysisExecutor = 'inline' | 'workers' | 'auto';
8
- export type MarkdownProjectAnalysis = {
9
- latDir: string;
10
- projectRoot: string;
11
- entries: string[];
12
- markdownFiles: string[];
13
- files: ReadonlyMap<string, MarkdownFileAnalysis>;
14
- filesByAbsolutePath: ReadonlyMap<string, MarkdownFileAnalysis>;
15
- allSections: Section[];
16
- sections: Section[];
17
- sectionById: ReadonlyMap<string, Section>;
18
- sectionIds: ReadonlySet<string>;
19
- fileIndex: Map<string, string[]>;
20
- slugIndex: SectionSlugIndex;
21
- wikiRefs: readonly Ref[];
22
- outgoingRefsBySection: ReadonlyMap<string, readonly Ref[]>;
23
- refsByTarget: ReadonlyMap<string, readonly Ref[]>;
24
- incomingRefsBySection: ReadonlyMap<string, readonly Ref[]>;
25
- };
26
- export type AnalyzeMarkdownProjectOptions = {
27
- executor?: MarkdownAnalysisExecutor;
28
- maxWorkers?: number;
29
- cache?: boolean;
30
- onFileAnalyzed?: (analysis: MarkdownFileAnalysis) => void;
31
- onParserImport?: ParserImportObserver;
32
- };
33
- /** Read and analyze every Markdown file into one immutable command snapshot. */
34
- export declare function analyzeMarkdownProject(latDir: string, projectRoot: string, options?: AnalyzeMarkdownProjectOptions): Promise<MarkdownProjectAnalysis>;
35
- /** Lazy request-scoped owner for one immutable project analysis. */
36
- export declare class MarkdownProjectSession {
37
- readonly latDir: string;
38
- readonly projectRoot: string;
39
- readonly options: AnalyzeMarkdownProjectOptions;
40
- private analysisPromise?;
41
- private codeRefsPromise?;
42
- private externalPromise?;
43
- private readonly sourceParserRuntime;
44
- constructor(latDir: string, projectRoot: string, options?: AnalyzeMarkdownProjectOptions);
45
- analysis(): Promise<MarkdownProjectAnalysis>;
46
- codeRefs(): Promise<ScanResult>;
47
- external(): Promise<ExternalResolver>;
48
- sourceSymbolOptions(): ResolveSourceSymbolOptions;
49
- }
50
- type AnalysisContext = {
51
- latDir: string;
52
- projectRoot: string;
53
- analysis?: MarkdownProjectSession;
54
- };
55
- /** Reuse one lazy project snapshot throughout a CLI or MCP request. */
56
- export declare function commandProjectAnalysis(context: AnalysisContext): Promise<MarkdownProjectAnalysis>;
57
- /** Obtain the complete lazy request session for nested semantic operations. */
58
- export declare function commandProjectSession(context: AnalysisContext): MarkdownProjectSession;
59
- export {};
@@ -1,233 +0,0 @@
1
- import { availableParallelism } from 'node:os';
2
- import { join } from 'node:path';
3
- import { Worker } from 'node:worker_threads';
4
- import { buildFileIndex, buildSectionSlugIndex, flattenSections, resolveRef, } from './lattice-model.js';
5
- import { prepareMarkdownAnalysis, publishMarkdownAnalysis, } from './markdown-analysis-cache.js';
6
- import { walkEntries } from './walk.js';
7
- import { scanCodeRefs } from './code-refs.js';
8
- import { SourceParserRuntime, } from './source-parser.js';
9
- import { createExternalResolver, } from './external-sources.js';
10
- import { loadMarkdownAnalyzer } from './markdown-analyzer-loader.js';
11
- async function analyzeInline(files, latDir, projectRoot, onParserImport) {
12
- if (files.length === 0)
13
- return [];
14
- const analyzeMarkdownFile = await loadMarkdownAnalyzer(onParserImport, 'main thread');
15
- return Promise.all(files.map((file) => publishMarkdownAnalysis(file, analyzeMarkdownFile(file.absolutePath, file.content, latDir, projectRoot))));
16
- }
17
- function runWorkerTask(worker, task) {
18
- return new Promise((resolve, reject) => {
19
- const onMessage = (response) => {
20
- cleanup();
21
- if ('error' in response) {
22
- reject(new Error(`Failed to analyze ${task.absolutePath}: ${response.error}`));
23
- }
24
- else {
25
- resolve(response);
26
- }
27
- };
28
- const onError = (error) => {
29
- cleanup();
30
- reject(error);
31
- };
32
- const onExit = (code) => {
33
- cleanup();
34
- reject(new Error(`Markdown analysis worker exited with code ${code} while reading ${task.absolutePath}`));
35
- };
36
- const cleanup = () => {
37
- worker.off('message', onMessage);
38
- worker.off('error', onError);
39
- worker.off('exit', onExit);
40
- };
41
- worker.once('message', onMessage);
42
- worker.once('error', onError);
43
- worker.once('exit', onExit);
44
- worker.postMessage(task);
45
- });
46
- }
47
- async function analyzeWithWorkers(files, latDir, projectRoot, maxWorkers, onParserImport) {
48
- const workerCount = Math.max(1, Math.min(files.length, maxWorkers ?? 10, Math.max(1, availableParallelism() - 1)));
49
- const workers = Array.from({ length: workerCount }, () => {
50
- const sourceRuntime = import.meta.url.endsWith('.ts');
51
- return new Worker(new URL(sourceRuntime
52
- ? './markdown-analysis-worker.ts'
53
- : './markdown-analysis-worker.js', import.meta.url), {
54
- execArgv: sourceRuntime
55
- ? ['--import', 'tsx']
56
- : process.execArgv.filter((argument) => !argument.startsWith('--input-type')),
57
- });
58
- });
59
- const analyses = new Array(files.length);
60
- let next = 0;
61
- try {
62
- await Promise.all(workers.map(async (worker, workerIndex) => {
63
- while (true) {
64
- const id = next++;
65
- if (id >= files.length)
66
- return;
67
- const file = files[id];
68
- const response = await runWorkerTask(worker, {
69
- id,
70
- absolutePath: file.absolutePath,
71
- content: file.content,
72
- latDir,
73
- projectRoot,
74
- });
75
- analyses[id] = response.analysis;
76
- if (response.importMs !== undefined) {
77
- onParserImport?.({
78
- parser: 'Markdown analyzer',
79
- imported: true,
80
- durationMs: response.importMs,
81
- detail: `worker ${workerIndex + 1}`,
82
- });
83
- }
84
- }
85
- }));
86
- return Promise.all(analyses.map((analysis, index) => publishMarkdownAnalysis(files[index], analysis)));
87
- }
88
- finally {
89
- await Promise.all(workers.map((worker) => worker.terminate()));
90
- }
91
- }
92
- /** Read and analyze every Markdown file into one immutable command snapshot. */
93
- export async function analyzeMarkdownProject(latDir, projectRoot, options = {}) {
94
- const entries = await walkEntries(latDir);
95
- const markdownFiles = entries
96
- .filter((entry) => entry.endsWith('.md'))
97
- .sort()
98
- .map((entry) => join(latDir, entry));
99
- const prepared = await Promise.all(markdownFiles.map((absolutePath) => prepareMarkdownAnalysis(absolutePath, latDir, projectRoot, options.cache !== false)));
100
- const analyses = new Array(markdownFiles.length);
101
- const misses = [];
102
- const missIndexes = [];
103
- for (const [index, file] of prepared.entries()) {
104
- if (file.analysis)
105
- analyses[index] = file.analysis;
106
- else {
107
- misses.push(file);
108
- missIndexes.push(index);
109
- }
110
- }
111
- if (misses.length === 0) {
112
- options.onParserImport?.({
113
- parser: 'Markdown analyzer',
114
- imported: false,
115
- durationMs: 0,
116
- detail: prepared.length === 0
117
- ? 'no Markdown files'
118
- : `all ${prepared.length} Markdown files cached`,
119
- });
120
- }
121
- const executor = options.executor === 'auto' || options.executor === undefined
122
- ? misses.length >= 8
123
- ? 'workers'
124
- : 'inline'
125
- : options.executor;
126
- const parsed = executor === 'workers' && misses.length > 1
127
- ? await analyzeWithWorkers(misses, latDir, projectRoot, options.maxWorkers, options.onParserImport)
128
- : await analyzeInline(misses, latDir, projectRoot, options.onParserImport);
129
- for (const [index, analysis] of parsed.entries()) {
130
- analyses[missIndexes[index]] = analysis;
131
- }
132
- const files = new Map();
133
- const filesByAbsolutePath = new Map();
134
- for (const analysis of analyses) {
135
- files.set(analysis.path, analysis);
136
- filesByAbsolutePath.set(analysis.absolutePath, analysis);
137
- options.onFileAnalyzed?.(analysis);
138
- }
139
- const allSections = analyses.flatMap((analysis) => analysis.sections);
140
- const sections = flattenSections(allSections);
141
- const sectionById = new Map(sections.map((section) => [section.id.toLowerCase(), section]));
142
- const sectionIds = new Set(sectionById.keys());
143
- const fileIndex = buildFileIndex(allSections);
144
- const slugIndex = buildSectionSlugIndex(allSections);
145
- const wikiRefs = analyses.flatMap((analysis) => analysis.wikiRefs);
146
- const outgoingRefsBySection = new Map();
147
- const refsByTarget = new Map();
148
- const incomingRefsBySection = new Map();
149
- const append = (index, key, ref) => {
150
- const refs = index.get(key);
151
- if (refs)
152
- refs.push(ref);
153
- else
154
- index.set(key, [ref]);
155
- };
156
- for (const ref of wikiRefs) {
157
- const from = ref.fromSection.toLowerCase();
158
- const target = ref.target.toLowerCase();
159
- append(outgoingRefsBySection, from, ref);
160
- append(refsByTarget, target, ref);
161
- const resolved = resolveRef(ref.target, sectionIds, fileIndex, slugIndex);
162
- if (!resolved.ambiguous) {
163
- const resolvedId = resolved.resolved.toLowerCase();
164
- if (sectionIds.has(resolvedId)) {
165
- append(incomingRefsBySection, resolvedId, ref);
166
- }
167
- }
168
- }
169
- return {
170
- latDir,
171
- projectRoot,
172
- entries,
173
- markdownFiles,
174
- files,
175
- filesByAbsolutePath,
176
- allSections,
177
- sections,
178
- sectionById,
179
- sectionIds,
180
- fileIndex,
181
- slugIndex,
182
- wikiRefs,
183
- outgoingRefsBySection,
184
- refsByTarget,
185
- incomingRefsBySection,
186
- };
187
- }
188
- /** Lazy request-scoped owner for one immutable project analysis. */
189
- export class MarkdownProjectSession {
190
- latDir;
191
- projectRoot;
192
- options;
193
- analysisPromise;
194
- codeRefsPromise;
195
- externalPromise;
196
- sourceParserRuntime = new SourceParserRuntime();
197
- constructor(latDir, projectRoot, options = {}) {
198
- this.latDir = latDir;
199
- this.projectRoot = projectRoot;
200
- this.options = options;
201
- }
202
- analysis() {
203
- this.analysisPromise ??= analyzeMarkdownProject(this.latDir, this.projectRoot, this.options);
204
- return this.analysisPromise;
205
- }
206
- codeRefs() {
207
- this.codeRefsPromise ??= scanCodeRefs(this.projectRoot);
208
- return this.codeRefsPromise;
209
- }
210
- external() {
211
- this.externalPromise ??= (async () => {
212
- const resolver = await createExternalResolver(this.latDir, this.projectRoot);
213
- await resolver.reconcile();
214
- return resolver;
215
- })();
216
- return this.externalPromise;
217
- }
218
- sourceSymbolOptions() {
219
- return {
220
- latDir: this.latDir,
221
- runtime: this.sourceParserRuntime,
222
- };
223
- }
224
- }
225
- /** Reuse one lazy project snapshot throughout a CLI or MCP request. */
226
- export function commandProjectAnalysis(context) {
227
- return commandProjectSession(context).analysis();
228
- }
229
- /** Obtain the complete lazy request session for nested semantic operations. */
230
- export function commandProjectSession(context) {
231
- context.analysis ??= new MarkdownProjectSession(context.latDir, context.projectRoot);
232
- return context.analysis;
233
- }
@@ -1,6 +0,0 @@
1
- /** Find the nearest ancestor containing the project's lat.md directory. */
2
- export declare function findLatticeDir(from?: string): string | null;
3
- /** Find the root of the nearest project containing a lat.md directory. */
4
- export declare function findProjectRoot(from?: string): string | null;
5
- /** List project Markdown files without loading the Markdown parser. */
6
- export declare function listLatticeFiles(latticeDir: string): Promise<string[]>;
@@ -1,30 +0,0 @@
1
- import { existsSync, statSync } from 'node:fs';
2
- import { dirname, join, resolve } from 'node:path';
3
- /** Find the nearest ancestor containing the project's lat.md directory. */
4
- export function findLatticeDir(from) {
5
- let dir = resolve(from ?? process.cwd());
6
- while (true) {
7
- const candidate = join(dir, 'lat.md');
8
- if (existsSync(candidate) && statSync(candidate).isDirectory()) {
9
- return candidate;
10
- }
11
- const parent = dirname(dir);
12
- if (parent === dir)
13
- return null;
14
- dir = parent;
15
- }
16
- }
17
- /** Find the root of the nearest project containing a lat.md directory. */
18
- export function findProjectRoot(from) {
19
- const latDir = findLatticeDir(from);
20
- return latDir ? dirname(latDir) : null;
21
- }
22
- /** List project Markdown files without loading the Markdown parser. */
23
- export async function listLatticeFiles(latticeDir) {
24
- const { walkEntries } = await import('./walk.js');
25
- const entries = await walkEntries(latticeDir);
26
- return entries
27
- .filter((entry) => entry.endsWith('.md'))
28
- .sort()
29
- .map((entry) => join(latticeDir, entry));
30
- }
@@ -1,11 +0,0 @@
1
- export type RepositoryPathKind = 'directory' | 'file' | 'other';
2
- export type RepositoryPathInspection = {
3
- kind: RepositoryPathKind;
4
- realPath: string;
5
- } | {
6
- kind: 'missing' | 'outside';
7
- };
8
- /** Normalize a portable project-root-relative path without allowing escapes. */
9
- export declare function normalizeRepositoryPath(authoredPath: string): string | null;
10
- /** Inspect an existing path after resolving symlinks beneath the project root. */
11
- export declare function inspectRepositoryPath(projectRoot: string, path: string): Promise<RepositoryPathInspection>;
@@ -1,52 +0,0 @@
1
- import { realpath, stat } from 'node:fs/promises';
2
- import { isAbsolute, posix, relative, resolve, sep } from 'node:path';
3
- import { toPosix } from './path.js';
4
- /** Normalize a portable project-root-relative path without allowing escapes. */
5
- export function normalizeRepositoryPath(authoredPath) {
6
- if (!authoredPath || authoredPath.includes('\0'))
7
- return null;
8
- const portable = toPosix(authoredPath);
9
- if (posix.isAbsolute(portable) || /^[a-z]:\//i.test(portable))
10
- return null;
11
- const normalized = posix.normalize(portable).replace(/^\.\//, '');
12
- if (normalized === '..' ||
13
- normalized.startsWith('../') ||
14
- normalized.includes('\0')) {
15
- return null;
16
- }
17
- return normalized;
18
- }
19
- function isInside(root, candidate) {
20
- const path = relative(root, candidate);
21
- return (path === '' ||
22
- (!isAbsolute(path) && path !== '..' && !path.startsWith(`..${sep}`)));
23
- }
24
- /** Inspect an existing path after resolving symlinks beneath the project root. */
25
- export async function inspectRepositoryPath(projectRoot, path) {
26
- const candidate = resolve(projectRoot, ...path.split('/'));
27
- let realRoot;
28
- let realPath;
29
- try {
30
- [realRoot, realPath] = await Promise.all([
31
- realpath(projectRoot),
32
- realpath(candidate),
33
- ]);
34
- }
35
- catch {
36
- return { kind: 'missing' };
37
- }
38
- if (!isInside(realRoot, realPath))
39
- return { kind: 'outside' };
40
- try {
41
- const info = await stat(realPath);
42
- const kind = info.isFile()
43
- ? 'file'
44
- : info.isDirectory()
45
- ? 'directory'
46
- : 'other';
47
- return { kind, realPath };
48
- }
49
- catch {
50
- return { kind: 'missing' };
51
- }
52
- }
@@ -1,7 +0,0 @@
1
- /** Source file extensions supported by Lat's parser and code-reference scan. */
2
- export declare const SOURCE_FILE_EXTENSIONS: readonly [".c", ".dart", ".erb", ".go", ".h", ".java", ".js", ".jsx", ".php", ".py", ".rake", ".rb", ".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;
@@ -1,30 +0,0 @@
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
- '.erb',
7
- '.go',
8
- '.h',
9
- '.java',
10
- '.js',
11
- '.jsx',
12
- '.php',
13
- '.py',
14
- '.rake',
15
- '.rb',
16
- '.rs',
17
- '.ts',
18
- '.tsx',
19
- ];
20
- const sourceFileExtensionSet = new Set(SOURCE_FILE_EXTENSIONS);
21
- export function isSourceFileExtension(extension) {
22
- return sourceFileExtensionSet.has(extension);
23
- }
24
- export function sourceFileExtension(path) {
25
- const extension = extname(path);
26
- return isSourceFileExtension(extension) ? extension : null;
27
- }
28
- export function isSourceFilePath(path) {
29
- return sourceFileExtension(path) !== null;
30
- }
@@ -1,67 +0,0 @@
1
- import type { Section } from './lattice-model.js';
2
- export type SourceSymbol = {
3
- name: string;
4
- kind: 'function' | 'class' | 'const' | 'type' | 'interface' | 'method' | 'variable';
5
- parent?: string;
6
- startLine: number;
7
- endLine: number;
8
- signature: string;
9
- };
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
- };
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>;
52
- /** Clear the symbol cache. Call between top-level operations. */
53
- export declare function clearSymbolCache(): void;
54
- /**
55
- * Check whether a source file path (relative to projectRoot) has a given symbol.
56
- * Used by lat check to validate source code wiki links lazily.
57
- */
58
- export declare function resolveSourceSymbol(filePath: string, symbolPath: string, projectRoot: string, options?: ResolveSourceSymbolOptions): Promise<{
59
- found: boolean;
60
- symbols: SourceSymbol[];
61
- error?: string;
62
- }>;
63
- /**
64
- * Convert source symbols to Section objects for uniform handling.
65
- */
66
- export declare function sourceSymbolsToSections(symbols: SourceSymbol[], filePath: string): Section[];
67
- export {};