lmgrep 0.1.17 → 0.2.0

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 (401) hide show
  1. package/README.md +226 -63
  2. package/completions/_lmgrep +49 -40
  3. package/dist/application/Lmgrep.d.ts +107 -0
  4. package/dist/application/Lmgrep.js +99 -0
  5. package/dist/application/Lmgrep.js.map +1 -0
  6. package/dist/application/LmgrepFactory.d.ts +40 -0
  7. package/dist/application/LmgrepFactory.js +155 -0
  8. package/dist/application/LmgrepFactory.js.map +1 -0
  9. package/dist/application/indexing/BranchBootstrapper.d.ts +21 -0
  10. package/dist/application/indexing/BranchBootstrapper.js +52 -0
  11. package/dist/application/indexing/BranchBootstrapper.js.map +1 -0
  12. package/dist/application/indexing/BranchManifestSweeper.d.ts +17 -0
  13. package/dist/application/indexing/BranchManifestSweeper.js +35 -0
  14. package/dist/application/indexing/BranchManifestSweeper.js.map +1 -0
  15. package/dist/application/indexing/Duration.d.ts +9 -0
  16. package/dist/application/indexing/Duration.js +25 -0
  17. package/dist/application/indexing/Duration.js.map +1 -0
  18. package/dist/application/indexing/EmbeddingAbortError.d.ts +11 -0
  19. package/dist/application/indexing/EmbeddingAbortError.js +20 -0
  20. package/dist/application/indexing/EmbeddingAbortError.js.map +1 -0
  21. package/dist/application/indexing/EmbeddingPipeline.d.ts +59 -0
  22. package/dist/application/indexing/EmbeddingPipeline.js +140 -0
  23. package/dist/application/indexing/EmbeddingPipeline.js.map +1 -0
  24. package/dist/application/indexing/IndexBuilder.d.ts +112 -0
  25. package/dist/application/indexing/IndexBuilder.js +370 -0
  26. package/dist/application/indexing/IndexBuilder.js.map +1 -0
  27. package/dist/application/indexing/IndexingProgress.d.ts +34 -0
  28. package/dist/application/indexing/IndexingProgress.js +2 -0
  29. package/dist/application/indexing/IndexingProgress.js.map +1 -0
  30. package/dist/application/operations/Deadline.d.ts +13 -0
  31. package/dist/application/operations/Deadline.js +29 -0
  32. package/dist/application/operations/Deadline.js.map +1 -0
  33. package/dist/application/operations/HealthMonitor.d.ts +58 -0
  34. package/dist/application/operations/HealthMonitor.js +128 -0
  35. package/dist/application/operations/HealthMonitor.js.map +1 -0
  36. package/dist/application/operations/IndexAlternatives.d.ts +35 -0
  37. package/dist/application/operations/IndexAlternatives.js +61 -0
  38. package/dist/application/operations/IndexAlternatives.js.map +1 -0
  39. package/dist/application/operations/IndexInventory.d.ts +69 -0
  40. package/dist/application/operations/IndexInventory.js +99 -0
  41. package/dist/application/operations/IndexInventory.js.map +1 -0
  42. package/dist/application/operations/StatusService.d.ts +90 -0
  43. package/dist/application/operations/StatusService.js +171 -0
  44. package/dist/application/operations/StatusService.js.map +1 -0
  45. package/dist/application/operations/WatchService.d.ts +67 -0
  46. package/dist/application/operations/WatchService.js +145 -0
  47. package/dist/application/operations/WatchService.js.map +1 -0
  48. package/dist/application/operations/WorkingTreeDiff.d.ts +19 -0
  49. package/dist/application/operations/WorkingTreeDiff.js +36 -0
  50. package/dist/application/operations/WorkingTreeDiff.js.map +1 -0
  51. package/dist/application/research/ResearchAgent.d.ts +68 -0
  52. package/dist/application/research/ResearchAgent.js +201 -0
  53. package/dist/application/research/ResearchAgent.js.map +1 -0
  54. package/dist/application/research/ResearchPrompts.d.ts +16 -0
  55. package/dist/application/research/ResearchPrompts.js +34 -0
  56. package/dist/application/research/ResearchPrompts.js.map +1 -0
  57. package/dist/application/search/SearchCriteria.d.ts +37 -0
  58. package/dist/application/search/SearchCriteria.js +48 -0
  59. package/dist/application/search/SearchCriteria.js.map +1 -0
  60. package/dist/application/search/SearchService.d.ts +36 -0
  61. package/dist/application/search/SearchService.js +108 -0
  62. package/dist/application/search/SearchService.js.map +1 -0
  63. package/dist/application/search/SearchTargetResolver.d.ts +56 -0
  64. package/dist/application/search/SearchTargetResolver.js +104 -0
  65. package/dist/application/search/SearchTargetResolver.js.map +1 -0
  66. package/dist/cli.d.ts +1 -1
  67. package/dist/cli.js +5 -754
  68. package/dist/cli.js.map +1 -1
  69. package/dist/domain/config/ConfigSource.d.ts +16 -0
  70. package/dist/domain/config/ConfigSource.js +2 -0
  71. package/dist/domain/config/ConfigSource.js.map +1 -0
  72. package/dist/domain/config/LmgrepConfig.d.ts +53 -0
  73. package/dist/domain/config/LmgrepConfig.js +2 -0
  74. package/dist/domain/config/LmgrepConfig.js.map +1 -0
  75. package/dist/domain/corpus/Chunk.d.ts +49 -0
  76. package/dist/domain/corpus/Chunk.js +60 -0
  77. package/dist/domain/corpus/Chunk.js.map +1 -0
  78. package/dist/domain/corpus/CodeLocation.d.ts +18 -0
  79. package/dist/domain/corpus/CodeLocation.js +34 -0
  80. package/dist/domain/corpus/CodeLocation.js.map +1 -0
  81. package/dist/domain/corpus/ContentHash.d.ts +15 -0
  82. package/dist/domain/corpus/ContentHash.js +30 -0
  83. package/dist/domain/corpus/ContentHash.js.map +1 -0
  84. package/dist/domain/corpus/FileVersion.d.ts +31 -0
  85. package/dist/domain/corpus/FileVersion.js +47 -0
  86. package/dist/domain/corpus/FileVersion.js.map +1 -0
  87. package/dist/domain/corpus/SourceFile.d.ts +26 -0
  88. package/dist/domain/corpus/SourceFile.js +47 -0
  89. package/dist/domain/corpus/SourceFile.js.map +1 -0
  90. package/dist/domain/corpus/Vector.d.ts +37 -0
  91. package/dist/domain/corpus/Vector.js +96 -0
  92. package/dist/domain/corpus/Vector.js.map +1 -0
  93. package/dist/domain/ports/ChatModelPort.d.ts +57 -0
  94. package/dist/domain/ports/ChatModelPort.js +2 -0
  95. package/dist/domain/ports/ChatModelPort.js.map +1 -0
  96. package/dist/domain/ports/ChunkRepositoryPort.d.ts +42 -0
  97. package/dist/domain/ports/ChunkRepositoryPort.js +2 -0
  98. package/dist/domain/ports/ChunkRepositoryPort.js.map +1 -0
  99. package/dist/domain/ports/ChunkerPort.d.ts +5 -0
  100. package/dist/domain/ports/ChunkerPort.js +2 -0
  101. package/dist/domain/ports/ChunkerPort.js.map +1 -0
  102. package/dist/domain/ports/DatabaseSessionPort.d.ts +10 -0
  103. package/dist/domain/ports/DatabaseSessionPort.js +2 -0
  104. package/dist/domain/ports/DatabaseSessionPort.js.map +1 -0
  105. package/dist/domain/ports/EmbedderPort.d.ts +14 -0
  106. package/dist/domain/ports/EmbedderPort.js +2 -0
  107. package/dist/domain/ports/EmbedderPort.js.map +1 -0
  108. package/dist/domain/ports/FileManifestRepositoryPort.d.ts +32 -0
  109. package/dist/domain/ports/FileManifestRepositoryPort.js +2 -0
  110. package/dist/domain/ports/FileManifestRepositoryPort.js.map +1 -0
  111. package/dist/domain/ports/GitPort.d.ts +24 -0
  112. package/dist/domain/ports/GitPort.js +2 -0
  113. package/dist/domain/ports/GitPort.js.map +1 -0
  114. package/dist/domain/ports/IndexMaintenancePort.d.ts +58 -0
  115. package/dist/domain/ports/IndexMaintenancePort.js +2 -0
  116. package/dist/domain/ports/IndexMaintenancePort.js.map +1 -0
  117. package/dist/domain/ports/IndexMetadataPort.d.ts +23 -0
  118. package/dist/domain/ports/IndexMetadataPort.js +2 -0
  119. package/dist/domain/ports/IndexMetadataPort.js.map +1 -0
  120. package/dist/domain/ports/LockPort.d.ts +17 -0
  121. package/dist/domain/ports/LockPort.js +2 -0
  122. package/dist/domain/ports/LockPort.js.map +1 -0
  123. package/dist/domain/ports/LoggerPort.d.ts +5 -0
  124. package/dist/domain/ports/LoggerPort.js +2 -0
  125. package/dist/domain/ports/LoggerPort.js.map +1 -0
  126. package/dist/domain/ports/ProjectIndexesPort.d.ts +20 -0
  127. package/dist/domain/ports/ProjectIndexesPort.js +2 -0
  128. package/dist/domain/ports/ProjectIndexesPort.js.map +1 -0
  129. package/dist/domain/ports/ProjectRegistryPort.d.ts +42 -0
  130. package/dist/domain/ports/ProjectRegistryPort.js +2 -0
  131. package/dist/domain/ports/ProjectRegistryPort.js.map +1 -0
  132. package/dist/domain/ports/StateDirectoryPort.d.ts +29 -0
  133. package/dist/domain/ports/StateDirectoryPort.js +2 -0
  134. package/dist/domain/ports/StateDirectoryPort.js.map +1 -0
  135. package/dist/domain/ports/WorkspacePort.d.ts +38 -0
  136. package/dist/domain/ports/WorkspacePort.js +2 -0
  137. package/dist/domain/ports/WorkspacePort.js.map +1 -0
  138. package/dist/domain/project/Branch.d.ts +20 -0
  139. package/dist/domain/project/Branch.js +33 -0
  140. package/dist/domain/project/Branch.js.map +1 -0
  141. package/dist/domain/project/DatabaseLocation.d.ts +32 -0
  142. package/dist/domain/project/DatabaseLocation.js +35 -0
  143. package/dist/domain/project/DatabaseLocation.js.map +1 -0
  144. package/dist/domain/project/IndexMetadata.d.ts +17 -0
  145. package/dist/domain/project/IndexMetadata.js +2 -0
  146. package/dist/domain/project/IndexMetadata.js.map +1 -0
  147. package/dist/domain/project/ModelIdentity.d.ts +58 -0
  148. package/dist/domain/project/ModelIdentity.js +97 -0
  149. package/dist/domain/project/ModelIdentity.js.map +1 -0
  150. package/dist/domain/project/Project.d.ts +17 -0
  151. package/dist/domain/project/Project.js +21 -0
  152. package/dist/domain/project/Project.js.map +1 -0
  153. package/dist/domain/project/ProjectId.d.ts +28 -0
  154. package/dist/domain/project/ProjectId.js +58 -0
  155. package/dist/domain/project/ProjectId.js.map +1 -0
  156. package/dist/domain/project/ProjectLocator.d.ts +112 -0
  157. package/dist/domain/project/ProjectLocator.js +178 -0
  158. package/dist/domain/project/ProjectLocator.js.map +1 -0
  159. package/dist/domain/research/Citation.d.ts +27 -0
  160. package/dist/domain/research/Citation.js +43 -0
  161. package/dist/domain/research/Citation.js.map +1 -0
  162. package/dist/domain/research/EvidenceLedger.d.ts +47 -0
  163. package/dist/domain/research/EvidenceLedger.js +111 -0
  164. package/dist/domain/research/EvidenceLedger.js.map +1 -0
  165. package/dist/domain/research/ResearchTrace.d.ts +19 -0
  166. package/dist/domain/research/ResearchTrace.js +22 -0
  167. package/dist/domain/research/ResearchTrace.js.map +1 -0
  168. package/dist/domain/retrieval/Hit.d.ts +19 -0
  169. package/dist/domain/retrieval/Hit.js +28 -0
  170. package/dist/domain/retrieval/Hit.js.map +1 -0
  171. package/dist/domain/retrieval/HitList.d.ts +35 -0
  172. package/dist/domain/retrieval/HitList.js +81 -0
  173. package/dist/domain/retrieval/HitList.js.map +1 -0
  174. package/dist/domain/retrieval/MissingIndexError.d.ts +11 -0
  175. package/dist/domain/retrieval/MissingIndexError.js +15 -0
  176. package/dist/domain/retrieval/MissingIndexError.js.map +1 -0
  177. package/dist/index.d.ts +43 -33
  178. package/dist/index.js +32 -215
  179. package/dist/index.js.map +1 -1
  180. package/dist/infrastructure/ai/AiSdkChatModel.d.ts +31 -0
  181. package/dist/infrastructure/ai/AiSdkChatModel.js +137 -0
  182. package/dist/infrastructure/ai/AiSdkChatModel.js.map +1 -0
  183. package/dist/infrastructure/ai/AiSdkEmbedder.d.ts +28 -0
  184. package/dist/infrastructure/ai/AiSdkEmbedder.js +79 -0
  185. package/dist/infrastructure/ai/AiSdkEmbedder.js.map +1 -0
  186. package/dist/infrastructure/ai/EmbeddingPrefixes.d.ts +21 -0
  187. package/dist/infrastructure/ai/EmbeddingPrefixes.js +40 -0
  188. package/dist/infrastructure/ai/EmbeddingPrefixes.js.map +1 -0
  189. package/dist/infrastructure/ai/LmStudioProbe.d.ts +18 -0
  190. package/dist/infrastructure/ai/LmStudioProbe.js +49 -0
  191. package/dist/infrastructure/ai/LmStudioProbe.js.map +1 -0
  192. package/dist/infrastructure/ai/LocalModelReloader.d.ts +21 -0
  193. package/dist/infrastructure/ai/LocalModelReloader.js +61 -0
  194. package/dist/infrastructure/ai/LocalModelReloader.js.map +1 -0
  195. package/dist/infrastructure/ai/LocalRuntimeDetector.d.ts +36 -0
  196. package/dist/infrastructure/ai/LocalRuntimeDetector.js +61 -0
  197. package/dist/infrastructure/ai/LocalRuntimeDetector.js.map +1 -0
  198. package/dist/infrastructure/ai/ModelRuntime.d.ts +32 -0
  199. package/dist/infrastructure/ai/ModelRuntime.js +2 -0
  200. package/dist/infrastructure/ai/ModelRuntime.js.map +1 -0
  201. package/dist/infrastructure/ai/OllamaProbe.d.ts +21 -0
  202. package/dist/infrastructure/ai/OllamaProbe.js +69 -0
  203. package/dist/infrastructure/ai/OllamaProbe.js.map +1 -0
  204. package/dist/infrastructure/ai/ProviderFailure.d.ts +16 -0
  205. package/dist/infrastructure/ai/ProviderFailure.js +35 -0
  206. package/dist/infrastructure/ai/ProviderFailure.js.map +1 -0
  207. package/dist/infrastructure/ai/ProviderModuleLoader.d.ts +13 -0
  208. package/dist/infrastructure/ai/ProviderModuleLoader.js +49 -0
  209. package/dist/infrastructure/ai/ProviderModuleLoader.js.map +1 -0
  210. package/dist/infrastructure/ai/ProviderRegistry.d.ts +37 -0
  211. package/dist/infrastructure/ai/ProviderRegistry.js +55 -0
  212. package/dist/infrastructure/ai/ProviderRegistry.js.map +1 -0
  213. package/dist/infrastructure/fs/ConfigLoader.d.ts +59 -0
  214. package/dist/infrastructure/fs/ConfigLoader.js +194 -0
  215. package/dist/infrastructure/fs/ConfigLoader.js.map +1 -0
  216. package/dist/infrastructure/fs/DatabaseLocks.d.ts +52 -0
  217. package/dist/infrastructure/fs/DatabaseLocks.js +92 -0
  218. package/dist/infrastructure/fs/DatabaseLocks.js.map +1 -0
  219. package/dist/infrastructure/fs/DiskUsage.d.ts +6 -0
  220. package/dist/infrastructure/fs/DiskUsage.js +41 -0
  221. package/dist/infrastructure/fs/DiskUsage.js.map +1 -0
  222. package/dist/infrastructure/fs/IndexableFileRules.d.ts +33 -0
  223. package/dist/infrastructure/fs/IndexableFileRules.js +177 -0
  224. package/dist/infrastructure/fs/IndexableFileRules.js.map +1 -0
  225. package/dist/infrastructure/fs/Loggers.d.ts +14 -0
  226. package/dist/infrastructure/fs/Loggers.js +18 -0
  227. package/dist/infrastructure/fs/Loggers.js.map +1 -0
  228. package/dist/infrastructure/fs/PidFileLock.d.ts +40 -0
  229. package/dist/infrastructure/fs/PidFileLock.js +97 -0
  230. package/dist/infrastructure/fs/PidFileLock.js.map +1 -0
  231. package/dist/infrastructure/fs/ProjectIndexes.d.ts +8 -0
  232. package/dist/infrastructure/fs/ProjectIndexes.js +35 -0
  233. package/dist/infrastructure/fs/ProjectIndexes.js.map +1 -0
  234. package/dist/infrastructure/fs/ProjectMetadataStore.d.ts +42 -0
  235. package/dist/infrastructure/fs/ProjectMetadataStore.js +86 -0
  236. package/dist/infrastructure/fs/ProjectMetadataStore.js.map +1 -0
  237. package/dist/infrastructure/fs/ProjectRegistry.d.ts +25 -0
  238. package/dist/infrastructure/fs/ProjectRegistry.js +83 -0
  239. package/dist/infrastructure/fs/ProjectRegistry.js.map +1 -0
  240. package/dist/infrastructure/fs/StateDirectory.d.ts +28 -0
  241. package/dist/infrastructure/fs/StateDirectory.js +71 -0
  242. package/dist/infrastructure/fs/StateDirectory.js.map +1 -0
  243. package/dist/infrastructure/fs/Workspace.d.ts +25 -0
  244. package/dist/infrastructure/fs/Workspace.js +90 -0
  245. package/dist/infrastructure/fs/Workspace.js.map +1 -0
  246. package/dist/infrastructure/git/GitClient.d.ts +34 -0
  247. package/dist/infrastructure/git/GitClient.js +74 -0
  248. package/dist/infrastructure/git/GitClient.js.map +1 -0
  249. package/dist/infrastructure/lancedb/ChunkRepository.d.ts +38 -0
  250. package/dist/infrastructure/lancedb/ChunkRepository.js +166 -0
  251. package/dist/infrastructure/lancedb/ChunkRepository.js.map +1 -0
  252. package/dist/infrastructure/lancedb/DatabaseImporter.d.ts +22 -0
  253. package/dist/infrastructure/lancedb/DatabaseImporter.js +74 -0
  254. package/dist/infrastructure/lancedb/DatabaseImporter.js.map +1 -0
  255. package/dist/infrastructure/lancedb/FileManifestRepository.d.ts +34 -0
  256. package/dist/infrastructure/lancedb/FileManifestRepository.js +137 -0
  257. package/dist/infrastructure/lancedb/FileManifestRepository.js.map +1 -0
  258. package/dist/infrastructure/lancedb/IndexMaintenance.d.ts +53 -0
  259. package/dist/infrastructure/lancedb/IndexMaintenance.js +227 -0
  260. package/dist/infrastructure/lancedb/IndexMaintenance.js.map +1 -0
  261. package/dist/infrastructure/lancedb/LanceTables.d.ts +67 -0
  262. package/dist/infrastructure/lancedb/LanceTables.js +159 -0
  263. package/dist/infrastructure/lancedb/LanceTables.js.map +1 -0
  264. package/dist/infrastructure/lancedb/NativeTuning.d.ts +1 -0
  265. package/dist/infrastructure/lancedb/NativeTuning.js +9 -0
  266. package/dist/infrastructure/lancedb/NativeTuning.js.map +1 -0
  267. package/dist/infrastructure/lancedb/RowReplication.d.ts +27 -0
  268. package/dist/infrastructure/lancedb/RowReplication.js +82 -0
  269. package/dist/infrastructure/lancedb/RowReplication.js.map +1 -0
  270. package/dist/infrastructure/lancedb/VectorIndexPolicy.d.ts +60 -0
  271. package/dist/infrastructure/lancedb/VectorIndexPolicy.js +72 -0
  272. package/dist/infrastructure/lancedb/VectorIndexPolicy.js.map +1 -0
  273. package/dist/infrastructure/p2p/IndexShare.d.ts +45 -0
  274. package/dist/infrastructure/p2p/IndexShare.js +160 -0
  275. package/dist/infrastructure/p2p/IndexShare.js.map +1 -0
  276. package/dist/infrastructure/p2p/PeerSwarm.d.ts +16 -0
  277. package/dist/infrastructure/p2p/PeerSwarm.js +41 -0
  278. package/dist/infrastructure/p2p/PeerSwarm.js.map +1 -0
  279. package/dist/infrastructure/p2p/SecureChannel.d.ts +60 -0
  280. package/dist/infrastructure/p2p/SecureChannel.js +71 -0
  281. package/dist/infrastructure/p2p/SecureChannel.js.map +1 -0
  282. package/dist/infrastructure/p2p/ShareCode.d.ts +25 -0
  283. package/dist/infrastructure/p2p/ShareCode.js +304 -0
  284. package/dist/infrastructure/p2p/ShareCode.js.map +1 -0
  285. package/dist/infrastructure/process/ProcessRegistry.d.ts +50 -0
  286. package/dist/infrastructure/process/ProcessRegistry.js +109 -0
  287. package/dist/infrastructure/process/ProcessRegistry.js.map +1 -0
  288. package/dist/infrastructure/treesitter/ChunkContextBuilder.d.ts +45 -0
  289. package/dist/infrastructure/treesitter/ChunkContextBuilder.js +159 -0
  290. package/dist/infrastructure/treesitter/ChunkContextBuilder.js.map +1 -0
  291. package/dist/infrastructure/treesitter/LanguageCatalog.d.ts +30 -0
  292. package/dist/{lib/chunker/languages.js → infrastructure/treesitter/LanguageCatalog.js} +65 -41
  293. package/dist/infrastructure/treesitter/LanguageCatalog.js.map +1 -0
  294. package/dist/infrastructure/treesitter/SlidingWindowChunker.d.ts +15 -0
  295. package/dist/infrastructure/treesitter/SlidingWindowChunker.js +42 -0
  296. package/dist/infrastructure/treesitter/SlidingWindowChunker.js.map +1 -0
  297. package/dist/infrastructure/treesitter/TreeSitterChunker.d.ts +42 -0
  298. package/dist/infrastructure/treesitter/TreeSitterChunker.js +163 -0
  299. package/dist/infrastructure/treesitter/TreeSitterChunker.js.map +1 -0
  300. package/dist/mcp.d.ts +1 -1
  301. package/dist/mcp.js +15 -61
  302. package/dist/mcp.js.map +1 -1
  303. package/dist/presentation/cli/Cli.d.ts +31 -0
  304. package/dist/presentation/cli/Cli.js +120 -0
  305. package/dist/presentation/cli/Cli.js.map +1 -0
  306. package/dist/presentation/cli/CliOptions.d.ts +18 -0
  307. package/dist/presentation/cli/CliOptions.js +25 -0
  308. package/dist/presentation/cli/CliOptions.js.map +1 -0
  309. package/dist/presentation/cli/CommandContext.d.ts +50 -0
  310. package/dist/presentation/cli/CommandContext.js +88 -0
  311. package/dist/presentation/cli/CommandContext.js.map +1 -0
  312. package/dist/presentation/cli/ConfigTemplate.d.ts +31 -0
  313. package/dist/presentation/cli/ConfigTemplate.js +83 -0
  314. package/dist/presentation/cli/ConfigTemplate.js.map +1 -0
  315. package/dist/presentation/cli/Renderer.d.ts +90 -0
  316. package/dist/presentation/cli/Renderer.js +290 -0
  317. package/dist/presentation/cli/Renderer.js.map +1 -0
  318. package/dist/presentation/cli/commands/AskCommand.d.ts +14 -0
  319. package/dist/presentation/cli/commands/AskCommand.js +48 -0
  320. package/dist/presentation/cli/commands/AskCommand.js.map +1 -0
  321. package/dist/presentation/cli/commands/CompletionsCommand.d.ts +18 -0
  322. package/dist/presentation/cli/commands/CompletionsCommand.js +96 -0
  323. package/dist/presentation/cli/commands/CompletionsCommand.js.map +1 -0
  324. package/dist/presentation/cli/commands/ConfigCommands.d.ts +55 -0
  325. package/dist/presentation/cli/commands/ConfigCommands.js +204 -0
  326. package/dist/presentation/cli/commands/ConfigCommands.js.map +1 -0
  327. package/dist/presentation/cli/commands/IndexCommand.d.ts +18 -0
  328. package/dist/presentation/cli/commands/IndexCommand.js +54 -0
  329. package/dist/presentation/cli/commands/IndexCommand.js.map +1 -0
  330. package/dist/presentation/cli/commands/ProjectsCommand.d.ts +48 -0
  331. package/dist/presentation/cli/commands/ProjectsCommand.js +240 -0
  332. package/dist/presentation/cli/commands/ProjectsCommand.js.map +1 -0
  333. package/dist/presentation/cli/commands/SearchCommand.d.ts +19 -0
  334. package/dist/presentation/cli/commands/SearchCommand.js +55 -0
  335. package/dist/presentation/cli/commands/SearchCommand.js.map +1 -0
  336. package/dist/presentation/cli/commands/ServerCommands.d.ts +13 -0
  337. package/dist/presentation/cli/commands/ServerCommands.js +40 -0
  338. package/dist/presentation/cli/commands/ServerCommands.js.map +1 -0
  339. package/dist/presentation/cli/commands/ShareCommands.d.ts +22 -0
  340. package/dist/presentation/cli/commands/ShareCommands.js +134 -0
  341. package/dist/presentation/cli/commands/ShareCommands.js.map +1 -0
  342. package/dist/presentation/cli/commands/StatusCommand.d.ts +15 -0
  343. package/dist/presentation/cli/commands/StatusCommand.js +53 -0
  344. package/dist/presentation/cli/commands/StatusCommand.js.map +1 -0
  345. package/dist/presentation/mcp/HitFormatter.d.ts +17 -0
  346. package/dist/presentation/mcp/HitFormatter.js +42 -0
  347. package/dist/presentation/mcp/HitFormatter.js.map +1 -0
  348. package/dist/presentation/mcp/IndexWatchController.d.ts +17 -0
  349. package/dist/presentation/mcp/IndexWatchController.js +31 -0
  350. package/dist/presentation/mcp/IndexWatchController.js.map +1 -0
  351. package/dist/presentation/mcp/LmgrepCore.d.ts +66 -0
  352. package/dist/presentation/mcp/LmgrepCore.js +178 -0
  353. package/dist/presentation/mcp/LmgrepCore.js.map +1 -0
  354. package/dist/presentation/mcp/McpServer.d.ts +18 -0
  355. package/dist/presentation/mcp/McpServer.js +63 -0
  356. package/dist/presentation/mcp/McpServer.js.map +1 -0
  357. package/dist/presentation/mcp/ToolDescriptions.d.ts +40 -0
  358. package/dist/presentation/mcp/ToolDescriptions.js +85 -0
  359. package/dist/presentation/mcp/ToolDescriptions.js.map +1 -0
  360. package/package.json +84 -63
  361. package/dist/lib/build.d.ts +0 -7
  362. package/dist/lib/build.js +0 -284
  363. package/dist/lib/build.js.map +0 -1
  364. package/dist/lib/chunker/context.d.ts +0 -21
  365. package/dist/lib/chunker/context.js +0 -131
  366. package/dist/lib/chunker/context.js.map +0 -1
  367. package/dist/lib/chunker/index.d.ts +0 -7
  368. package/dist/lib/chunker/index.js +0 -150
  369. package/dist/lib/chunker/index.js.map +0 -1
  370. package/dist/lib/chunker/languages.d.ts +0 -15
  371. package/dist/lib/chunker/languages.js.map +0 -1
  372. package/dist/lib/config.d.ts +0 -12
  373. package/dist/lib/config.js +0 -83
  374. package/dist/lib/config.js.map +0 -1
  375. package/dist/lib/embedder.d.ts +0 -55
  376. package/dist/lib/embedder.js +0 -221
  377. package/dist/lib/embedder.js.map +0 -1
  378. package/dist/lib/p2p.d.ts +0 -32
  379. package/dist/lib/p2p.js +0 -281
  380. package/dist/lib/p2p.js.map +0 -1
  381. package/dist/lib/providers.d.ts +0 -1
  382. package/dist/lib/providers.js +0 -41
  383. package/dist/lib/providers.js.map +0 -1
  384. package/dist/lib/repair.d.ts +0 -10
  385. package/dist/lib/repair.js +0 -57
  386. package/dist/lib/repair.js.map +0 -1
  387. package/dist/lib/scanner.d.ts +0 -34
  388. package/dist/lib/scanner.js +0 -242
  389. package/dist/lib/scanner.js.map +0 -1
  390. package/dist/lib/search-tool.d.ts +0 -47
  391. package/dist/lib/search-tool.js +0 -239
  392. package/dist/lib/search-tool.js.map +0 -1
  393. package/dist/lib/serve.d.ts +0 -11
  394. package/dist/lib/serve.js +0 -127
  395. package/dist/lib/serve.js.map +0 -1
  396. package/dist/lib/store.d.ts +0 -177
  397. package/dist/lib/store.js +0 -825
  398. package/dist/lib/store.js.map +0 -1
  399. package/dist/lib/types.d.ts +0 -129
  400. package/dist/lib/types.js +0 -13
  401. package/dist/lib/types.js.map +0 -1
@@ -0,0 +1,109 @@
1
+ import { readdirSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { PidFileLock } from "../fs/PidFileLock.js";
4
+ /**
5
+ * Discovers which lmgrep processes are alive and what they hold.
6
+ *
7
+ * Maintainer lock files double as the registry: each records its owner's pid,
8
+ * worktree and database, so scanning them and testing liveness gives an
9
+ * accurate picture without any separate bookkeeping that could drift from
10
+ * reality.
11
+ */
12
+ export class ProcessRegistry {
13
+ state;
14
+ static LOCK_SUFFIX = ".lock";
15
+ constructor(state) {
16
+ this.state = state;
17
+ }
18
+ discoverRunning() {
19
+ const results = [];
20
+ // One process can hold several databases; report it once.
21
+ const seen = new Set();
22
+ for (const path of this.lockFiles()) {
23
+ const owner = new PidFileLock(path).read();
24
+ if (owner === undefined)
25
+ continue;
26
+ if (!PidFileLock.isAlive(owner.pid) || seen.has(owner.pid))
27
+ continue;
28
+ seen.add(owner.pid);
29
+ const info = this.inspect(owner.pid);
30
+ if (!info)
31
+ continue;
32
+ results.push({
33
+ pid: owner.pid,
34
+ processName: info.name,
35
+ cmdline: info.cmdline,
36
+ kind: this.classify(info),
37
+ // The lock records the worktree its owner actually watches,
38
+ // which is what the user wants to see — several worktrees can
39
+ // share one database, so the database's own recorded root
40
+ // would name the wrong tree.
41
+ projectRoot: owner.root,
42
+ databasePath: owner.database,
43
+ // Every lock in this scan is a maintainer lock, and only a
44
+ // watcher ever takes one — so holding it *is* watching. This
45
+ // used to be inferred from the command line, which cannot
46
+ // work: setting process.title overwrites that buffer, so the
47
+ // subcommand a process was launched with is no longer there
48
+ // to match against.
49
+ watching: true,
50
+ });
51
+ }
52
+ return results;
53
+ }
54
+ /**
55
+ * Lock files, from the locks directory and from the state root.
56
+ *
57
+ * The root is scanned too because a watcher started before locks moved is
58
+ * still running and still holds its database — reporting "no running
59
+ * processes" right after an upgrade would be wrong in exactly the moment
60
+ * someone is most likely to check.
61
+ */
62
+ lockFiles() {
63
+ const out = [];
64
+ for (const directory of [this.state.locksDirectory(), this.state.root()]) {
65
+ let entries;
66
+ try {
67
+ entries = readdirSync(directory);
68
+ }
69
+ catch {
70
+ continue;
71
+ }
72
+ for (const entry of entries) {
73
+ if (entry.endsWith(ProcessRegistry.LOCK_SUFFIX)) {
74
+ out.push(join(directory, entry));
75
+ }
76
+ }
77
+ }
78
+ return out;
79
+ }
80
+ inspect(pid) {
81
+ try {
82
+ return {
83
+ name: readFileSync(`/proc/${pid}/comm`, "utf-8").trim(),
84
+ cmdline: readFileSync(`/proc/${pid}/cmdline`, "utf-8")
85
+ .replace(/\0/g, " ")
86
+ .trim(),
87
+ };
88
+ }
89
+ catch {
90
+ // No procfs (macOS) or the process exited mid-scan.
91
+ return undefined;
92
+ }
93
+ }
94
+ /**
95
+ * What kind of process this is, from its title.
96
+ *
97
+ * The title is the only reliable signal: `process.title` rewrites the argv
98
+ * buffer, so /proc/<pid>/cmdline reads back as the title alone and carries
99
+ * no subcommand. The MCP entry point titles itself distinctly; anything
100
+ * else holding a maintainer lock reached it through `lmgrep serve`.
101
+ */
102
+ classify(info) {
103
+ if (info.name === "lmgrep-mcp" || info.cmdline.includes("mcp")) {
104
+ return "mcp";
105
+ }
106
+ return "serve";
107
+ }
108
+ }
109
+ //# sourceMappingURL=ProcessRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcessRegistry.js","sourceRoot":"","sources":["../../../src/infrastructure/process/ProcessRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,s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OAAO,KAAK,CAAC;QACd,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { Node } from "web-tree-sitter";
2
+ import type { LanguageConfig } from "./LanguageCatalog.js";
3
+ /** What kind of thing a chunk is, structurally. */
4
+ export type StructuralRole = "definition" | "orchestration" | "implementation";
5
+ /** One enclosing scope, e.g. `class Foo`. */
6
+ export interface ScopeEntry {
7
+ kind: string;
8
+ name: string;
9
+ }
10
+ /**
11
+ * Builds the context header prepended to a chunk before embedding.
12
+ *
13
+ * The header is what makes an isolated function retrievable: on its own,
14
+ * `async function handle(req)` shares little vocabulary with "how are webhooks
15
+ * authenticated", but stamped with its file, enclosing class and doc comment
16
+ * it does. Retrieval quality depends on this at least as much as on the text.
17
+ */
18
+ export declare class ChunkContextBuilder {
19
+ /** How far above a node to look for its doc comment. */
20
+ private static readonly MAX_COMMENT_LOOKBACK;
21
+ /** AST node type -> the word used for it in the header. */
22
+ private static readonly SCOPE_KINDS;
23
+ /** Node types that declare a shape rather than behaviour. */
24
+ private static readonly DEFINITION_TYPES;
25
+ /** Node types that wire things together rather than implement them. */
26
+ private static readonly ORCHESTRATION_TYPES;
27
+ /** The full header for one chunk. */
28
+ build(node: Node, filePath: string, source: string, language: LanguageConfig): string;
29
+ /** The minimal header for a file with no parsed structure. */
30
+ buildFileOnly(filePath: string): string;
31
+ /** Walk up from a node collecting the named scopes that enclose it. */
32
+ extractScope(node: Node, language: LanguageConfig): ScopeEntry[];
33
+ /**
34
+ * Collect the comment block or decorators immediately above a node.
35
+ *
36
+ * A blank line ends the block only once something has been collected, so a
37
+ * comment separated from its node by whitespace is still picked up, while
38
+ * unrelated code above it is not.
39
+ */
40
+ extractLeadingComment(node: Node, source: string): string | null;
41
+ classifyRole(node: Node): StructuralRole;
42
+ /** Comment syntax across every supported language, plus decorators. */
43
+ private looksLikeCommentOrDecorator;
44
+ private nodeName;
45
+ }
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Builds the context header prepended to a chunk before embedding.
3
+ *
4
+ * The header is what makes an isolated function retrievable: on its own,
5
+ * `async function handle(req)` shares little vocabulary with "how are webhooks
6
+ * authenticated", but stamped with its file, enclosing class and doc comment
7
+ * it does. Retrieval quality depends on this at least as much as on the text.
8
+ */
9
+ export class ChunkContextBuilder {
10
+ /** How far above a node to look for its doc comment. */
11
+ static MAX_COMMENT_LOOKBACK = 10;
12
+ /** AST node type -> the word used for it in the header. */
13
+ static SCOPE_KINDS = {
14
+ // TypeScript / JavaScript
15
+ class_declaration: "class",
16
+ class_body: "class",
17
+ interface_declaration: "interface",
18
+ module: "module",
19
+ namespace_declaration: "namespace",
20
+ // Python
21
+ class_definition: "class",
22
+ // Rust
23
+ impl_item: "impl",
24
+ trait_item: "trait",
25
+ mod_item: "mod",
26
+ // Go
27
+ type_declaration: "type",
28
+ // Ruby
29
+ class: "class",
30
+ // C / C++
31
+ struct_specifier: "struct",
32
+ class_specifier: "class",
33
+ namespace_definition: "namespace",
34
+ // Swift
35
+ struct_declaration: "struct",
36
+ extension_declaration: "extension",
37
+ // Scala
38
+ object_definition: "object",
39
+ trait_definition: "trait",
40
+ // Generic
41
+ ContainerDecl: "container",
42
+ };
43
+ /** Node types that declare a shape rather than behaviour. */
44
+ static DEFINITION_TYPES = new Set([
45
+ "class_declaration",
46
+ "class_definition",
47
+ "interface_declaration",
48
+ "type_alias_declaration",
49
+ "enum_declaration",
50
+ "struct_item",
51
+ "enum_item",
52
+ "trait_item",
53
+ "type_item",
54
+ "type_declaration",
55
+ "struct_specifier",
56
+ "class_specifier",
57
+ "enum_specifier",
58
+ "type_definition",
59
+ "struct_declaration",
60
+ "protocol_declaration",
61
+ "trait_definition",
62
+ "ContainerDecl",
63
+ ]);
64
+ /** Node types that wire things together rather than implement them. */
65
+ static ORCHESTRATION_TYPES = new Set([
66
+ "export_statement",
67
+ "decorated_definition",
68
+ ]);
69
+ /** The full header for one chunk. */
70
+ build(node, filePath, source, language) {
71
+ const lines = [
72
+ `[file: ${filePath}]`,
73
+ `[role: ${this.classifyRole(node)}]`,
74
+ ];
75
+ const scope = this.extractScope(node, language);
76
+ if (scope.length > 0) {
77
+ lines.push(`[scope: ${scope.map((s) => `${s.kind} ${s.name}`).join(" > ")}]`);
78
+ }
79
+ const comment = this.extractLeadingComment(node, source);
80
+ if (comment)
81
+ lines.push(`[doc: ${comment}]`);
82
+ return lines.join("\n");
83
+ }
84
+ /** The minimal header for a file with no parsed structure. */
85
+ buildFileOnly(filePath) {
86
+ return `[file: ${filePath}]`;
87
+ }
88
+ /** Walk up from a node collecting the named scopes that enclose it. */
89
+ extractScope(node, language) {
90
+ const scopes = [];
91
+ let current = node.parent;
92
+ while (current) {
93
+ if (language.scopeTypes.includes(current.type)) {
94
+ const name = this.nodeName(current);
95
+ if (name) {
96
+ scopes.unshift({
97
+ kind: ChunkContextBuilder.SCOPE_KINDS[current.type] ?? current.type,
98
+ name,
99
+ });
100
+ }
101
+ }
102
+ current = current.parent;
103
+ }
104
+ return scopes;
105
+ }
106
+ /**
107
+ * Collect the comment block or decorators immediately above a node.
108
+ *
109
+ * A blank line ends the block only once something has been collected, so a
110
+ * comment separated from its node by whitespace is still picked up, while
111
+ * unrelated code above it is not.
112
+ */
113
+ extractLeadingComment(node, source) {
114
+ const lines = source.split("\n");
115
+ const start = node.startPosition.row;
116
+ const collected = [];
117
+ for (let i = start - 1; i >= 0 && i >= start - ChunkContextBuilder.MAX_COMMENT_LOOKBACK; i--) {
118
+ const line = lines[i].trim();
119
+ if (this.looksLikeCommentOrDecorator(line)) {
120
+ collected.unshift(lines[i]);
121
+ }
122
+ else if (line === "") {
123
+ if (collected.length > 0)
124
+ break;
125
+ }
126
+ else {
127
+ break;
128
+ }
129
+ }
130
+ return collected.length === 0 ? null : collected.join("\n").trim();
131
+ }
132
+ classifyRole(node) {
133
+ if (ChunkContextBuilder.DEFINITION_TYPES.has(node.type)) {
134
+ return "definition";
135
+ }
136
+ if (ChunkContextBuilder.ORCHESTRATION_TYPES.has(node.type)) {
137
+ return "orchestration";
138
+ }
139
+ return "implementation";
140
+ }
141
+ /** Comment syntax across every supported language, plus decorators. */
142
+ looksLikeCommentOrDecorator(line) {
143
+ return (line.startsWith("//") ||
144
+ line.startsWith("#") ||
145
+ line.startsWith("*") ||
146
+ line.startsWith("/*") ||
147
+ line.startsWith("*/") ||
148
+ line.startsWith("///") ||
149
+ line.startsWith("--") ||
150
+ line.startsWith("@") ||
151
+ line.startsWith('"""') ||
152
+ line.startsWith("'''"));
153
+ }
154
+ nodeName(node) {
155
+ return (node.childForFieldName("name") ??
156
+ node.children.find((c) => c.type === "identifier" || c.type === "type_identifier"))?.text;
157
+ }
158
+ }
159
+ //# sourceMappingURL=ChunkContextBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChunkContextBuilder.js","sourceRoot":"","sources":["../../../src/infrastructure/treesitter/ChunkContextBuilder.ts"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAmB;IAC/B,wDAAwD;IAChD,MAAM,CAAU,oBAAoB,GAAG,EAAE,CAAC;IAElD,2DAA2D;IACnD,MAAM,CAAU,WAAW,GAA2B;QAC7D,0BAA0B;QAC1B,iBAAiB,EAAE,OAAO;QAC1B,UAAU,EAAE,OAAO;QACnB,qBAAqB,EAAE,WAAW;QAClC,MAAM,EAAE,QAAQ;QAChB,qBAAqB,EAAE,WAAW;QAClC,SAAS;QACT,gBAAgB,EAAE,OAAO;QACzB,OAAO;QACP,SAAS,EAAE,MAAM;QACjB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,KAAK;QACf,KAAK;QACL,gBAAgB,EAAE,MAAM;QACxB,OAAO;QACP,KAAK,EAAE,OAAO;QACd,UAAU;QACV,gBAAgB,EAAE,QAAQ;QAC1B,eAAe,EAAE,OAAO;QACxB,oBAAoB,EAAE,WAAW;QACjC,QAAQ;QACR,kBAAkB,EAAE,QAAQ;QAC5B,qBAAqB,EAAE,WAAW;QAClC,QA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,CAAC,CACtB,CAAC;IACH,CAAC;IAEO,QAAQ,CAAC,IAAU;QAC1B,OAAO,CACN,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC;YAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,CACjB,CAAC,CAAO,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,IAAI,CAAC,CAAC,IAAI,KAAK,iBAAiB,CACpE,CACD,EAAE,IAAI,CAAC;IACT,CAAC"}
@@ -0,0 +1,30 @@
1
+ export type LanguageId = "javascript" | "typescript" | "tsx" | "python" | "rust" | "go" | "ruby" | "c" | "cpp" | "swift" | "json" | "yaml" | "toml" | "lua" | "scala" | "zig" | "bash" | "html" | "css" | "java" | "kotlin" | "php" | "c_sharp" | "vue" | "markdown" | "nix";
2
+ export interface LanguageConfig {
3
+ id: LanguageId;
4
+ extensions: string[];
5
+ wasmFile: string;
6
+ /** AST node types that represent top-level or nestable definitions */
7
+ chunkTypes: string[];
8
+ /** AST node types that represent import/require statements */
9
+ importTypes: string[];
10
+ /** AST node types that represent class/struct/module wrappers */
11
+ scopeTypes: string[];
12
+ }
13
+ export declare const LANGUAGES: LanguageConfig[];
14
+ /**
15
+ * The grammar table and the lookups over it.
16
+ *
17
+ * Grammars ship as separate `@lumis-sh/wasm-<slug>` packages built for the
18
+ * current web-tree-sitter ABI, so resolution is a runtime `require.resolve`
19
+ * that may legitimately fail — a missing grammar means "chunk this file by
20
+ * sliding window", not an error.
21
+ */
22
+ export declare class LanguageCatalog {
23
+ private readonly languages;
24
+ private readonly byExtension;
25
+ constructor(languages?: readonly LanguageConfig[]);
26
+ /** Grammar for a path's extension, or undefined when none is known. */
27
+ forFile(filePath: string): LanguageConfig | undefined;
28
+ /** Absolute path to a grammar's wasm, or undefined when not installed. */
29
+ wasmPathFor(lang: LanguageConfig): string | undefined;
30
+ }
@@ -141,30 +141,21 @@ export const LANGUAGES = [
141
141
  "enum_specifier",
142
142
  ],
143
143
  importTypes: ["preproc_include", "using_declaration"],
144
- scopeTypes: [
145
- "class_specifier",
146
- "struct_specifier",
147
- "namespace_definition",
148
- ],
144
+ scopeTypes: ["class_specifier", "struct_specifier", "namespace_definition"],
149
145
  },
150
146
  {
151
147
  id: "swift",
152
148
  extensions: [".swift"],
153
149
  wasmFile: "tree-sitter-swift.wasm",
150
+ // Modern tree-sitter-swift represents struct/enum/extension/actor all as
151
+ // class_declaration (distinguished by keyword), so it covers them all.
154
152
  chunkTypes: [
155
153
  "function_declaration",
156
154
  "class_declaration",
157
- "struct_declaration",
158
- "enum_declaration",
159
155
  "protocol_declaration",
160
- "extension_declaration",
161
156
  ],
162
157
  importTypes: ["import_declaration"],
163
- scopeTypes: [
164
- "class_declaration",
165
- "struct_declaration",
166
- "extension_declaration",
167
- ],
158
+ scopeTypes: ["class_declaration"],
168
159
  },
169
160
  {
170
161
  id: "json",
@@ -194,11 +185,8 @@ export const LANGUAGES = [
194
185
  id: "lua",
195
186
  extensions: [".lua"],
196
187
  wasmFile: "tree-sitter-lua.wasm",
197
- chunkTypes: [
198
- "function_declaration",
199
- "local_function",
200
- "function_definition",
201
- ],
188
+ // Modern tree-sitter-lua folds `local function` into function_declaration.
189
+ chunkTypes: ["function_declaration", "function_definition"],
202
190
  importTypes: ["call"],
203
191
  scopeTypes: [],
204
192
  },
@@ -215,19 +203,19 @@ export const LANGUAGES = [
215
203
  "trait_definition",
216
204
  ],
217
205
  importTypes: ["import_declaration"],
218
- scopeTypes: [
219
- "class_definition",
220
- "object_definition",
221
- "trait_definition",
222
- ],
206
+ scopeTypes: ["class_definition", "object_definition", "trait_definition"],
223
207
  },
224
208
  {
225
209
  id: "zig",
226
210
  extensions: [".zig"],
227
211
  wasmFile: "tree-sitter-zig.wasm",
228
- chunkTypes: ["FnProto", "VarDecl", "ContainerDecl", "TestDecl"],
212
+ chunkTypes: [
213
+ "function_declaration",
214
+ "variable_declaration",
215
+ "test_declaration",
216
+ ],
229
217
  importTypes: [],
230
- scopeTypes: ["ContainerDecl"],
218
+ scopeTypes: ["struct_declaration", "enum_declaration", "union_declaration"],
231
219
  },
232
220
  {
233
221
  id: "bash",
@@ -303,7 +291,7 @@ export const LANGUAGES = [
303
291
  {
304
292
  id: "c_sharp",
305
293
  extensions: [".cs"],
306
- wasmFile: "tree-sitter-c_sharp.wasm",
294
+ wasmFile: "tree-sitter-csharp.wasm",
307
295
  chunkTypes: [
308
296
  "class_declaration",
309
297
  "interface_declaration",
@@ -330,23 +318,59 @@ export const LANGUAGES = [
330
318
  importTypes: [],
331
319
  scopeTypes: [],
332
320
  },
321
+ {
322
+ id: "markdown",
323
+ extensions: [".md", ".markdown", ".mdx"],
324
+ wasmFile: "tree-sitter-markdown.wasm",
325
+ // Markdown is chunked by a heading-aware splitter (see chunker), not by
326
+ // collectChunks — its `section` nodes nest, so emitting them whole would
327
+ // collapse a doc into one chunk. chunkTypes/scopeTypes are unused here.
328
+ chunkTypes: ["section"],
329
+ importTypes: [],
330
+ scopeTypes: ["section"],
331
+ },
332
+ {
333
+ id: "nix",
334
+ extensions: [".nix"],
335
+ wasmFile: "tree-sitter-nix.wasm",
336
+ chunkTypes: ["binding"],
337
+ importTypes: [],
338
+ scopeTypes: ["attrset_expression", "binding_set"],
339
+ },
333
340
  ];
334
- const extToLang = new Map();
335
- for (const lang of LANGUAGES) {
336
- for (const ext of lang.extensions) {
337
- extToLang.set(ext, lang);
341
+ /**
342
+ * The grammar table and the lookups over it.
343
+ *
344
+ * Grammars ship as separate `@lumis-sh/wasm-<slug>` packages built for the
345
+ * current web-tree-sitter ABI, so resolution is a runtime `require.resolve`
346
+ * that may legitimately fail — a missing grammar means "chunk this file by
347
+ * sliding window", not an error.
348
+ */
349
+ export class LanguageCatalog {
350
+ languages;
351
+ byExtension = new Map();
352
+ constructor(languages = LANGUAGES) {
353
+ this.languages = languages;
354
+ for (const lang of this.languages) {
355
+ for (const ext of lang.extensions)
356
+ this.byExtension.set(ext, lang);
357
+ }
338
358
  }
339
- }
340
- export function getLanguageForFile(filePath) {
341
- const ext = filePath.slice(filePath.lastIndexOf("."));
342
- return extToLang.get(ext);
343
- }
344
- export function getWasmPath(lang) {
345
- try {
346
- return require.resolve(`tree-sitter-wasms/out/${lang.wasmFile}`);
359
+ /** Grammar for a path's extension, or undefined when none is known. */
360
+ forFile(filePath) {
361
+ return this.byExtension.get(filePath.slice(filePath.lastIndexOf(".")));
347
362
  }
348
- catch {
349
- return undefined;
363
+ /** Absolute path to a grammar's wasm, or undefined when not installed. */
364
+ wasmPathFor(lang) {
365
+ const slug = lang.wasmFile
366
+ .replace(/^tree-sitter-/, "")
367
+ .replace(/\.wasm$/, "");
368
+ try {
369
+ return require.resolve(`@lumis-sh/wasm-${slug}/${lang.wasmFile}`);
370
+ }
371
+ catch {
372
+ return undefined;
373
+ }
350
374
  }
351
375
  }
352
- //# sourceMappingURL=languages.js.map
376
+ //# sourceMappingURL=LanguageCatalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LanguageCatalog.js","sourceRoot":"","sources":["../../../src/infrastructure/treesitter/LanguageCatalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AA0C/C,MAAM,CAAC,MAAM,SAAS,GAAqB;IAC1C;QACC,EAAE,EAAE,YAAY;QAChB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;QAC3B,QAAQ,EAAE,6BAA6B;QACvC,UAAU,EAAE;YACX,sBAAsB;YACtB,gBAAgB;YAChB,mBAAmB;YACnB,mBAAmB;YACnB,kBAAkB;YAClB,qBAAqB;SACrB;QACD,WAAW,EAAE,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;QACpD,UAAU,EAAE,CAAC,mBAAmB,EAAE,YAAY,CAAC;KAC/C;IACD;QACC,EAAE,EAAE,YAAY;QAChB,UAAU,EAAE,CAAC,KAAK,CAAC;Q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AC,OAAO,CAAC,kBAAkB,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnE,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,SAAS,CAAC;QAClB,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,15 @@
1
+ import { Chunk } from "../../domain/corpus/Chunk.js";
2
+ import type { ChunkerPort } from "../../domain/ports/ChunkerPort.js";
3
+ /**
4
+ * Fixed-size windows over a file, for sources with no grammar or no chunkable
5
+ * structure (a linear shell script, say).
6
+ *
7
+ * Windows overlap slightly so a passage straddling a boundary is still
8
+ * retrievable. The overlap is kept small because search deduplicates
9
+ * overlapping hits anyway, making a larger one pure index bloat.
10
+ */
11
+ export declare class SlidingWindowChunker implements ChunkerPort {
12
+ private static readonly WINDOW_LINES;
13
+ private static readonly STRIDE_LINES;
14
+ chunk(filePath: string, cwd: string): Promise<Chunk[]>;
15
+ }
@@ -0,0 +1,42 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { Chunk } from "../../domain/corpus/Chunk.js";
4
+ import { CodeLocation } from "../../domain/corpus/CodeLocation.js";
5
+ import { ContentHash } from "../../domain/corpus/ContentHash.js";
6
+ /**
7
+ * Fixed-size windows over a file, for sources with no grammar or no chunkable
8
+ * structure (a linear shell script, say).
9
+ *
10
+ * Windows overlap slightly so a passage straddling a boundary is still
11
+ * retrievable. The overlap is kept small because search deduplicates
12
+ * overlapping hits anyway, making a larger one pure index bloat.
13
+ */
14
+ export class SlidingWindowChunker {
15
+ static WINDOW_LINES = 50;
16
+ static STRIDE_LINES = 40;
17
+ async chunk(filePath, cwd) {
18
+ const source = readFileSync(join(cwd, filePath), "utf-8");
19
+ const lines = source.split("\n");
20
+ if (lines.length === 0)
21
+ return [];
22
+ const chunks = [];
23
+ for (let i = 0; i < lines.length; i += SlidingWindowChunker.STRIDE_LINES) {
24
+ const content = lines
25
+ .slice(i, i + SlidingWindowChunker.WINDOW_LINES)
26
+ .join("\n");
27
+ if (content.trim().length === 0)
28
+ continue;
29
+ const endLine = Math.min(i + SlidingWindowChunker.WINDOW_LINES, lines.length);
30
+ chunks.push(new Chunk({
31
+ location: new CodeLocation(filePath, i + 1, endLine),
32
+ type: "block",
33
+ name: `lines_${i + 1}_${endLine}`,
34
+ content,
35
+ context: `[file: ${filePath}]`,
36
+ hash: ContentHash.of(content),
37
+ }));
38
+ }
39
+ return chunks;
40
+ }
41
+ }
42
+ //# sourceMappingURL=SlidingWindowChunker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SlidingWindowChunker.js","sourceRoot":"","sources":["../../../src/infrastructure/treesitter/SlidingWindowChunker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE;;;;;;;GAOG;AACH,MAAM,OAAO,oBAAoB;IACxB,MAAM,CAAU,YAAY,GAAG,EAAE,CAAC;IAClC,MAAM,CAAU,YAAY,GAAG,EAAE,CAAC;IAE1C,KAAK,CAAC,KAAK,CAAC,QAAgB,EAAE,GAAW;QACxC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAElC,MAAM,MAAM,GAAY,EAAE,CAAC;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,oBAAoB,CAAC,YAAY,EAAE,CAAC;YAC1E,MAAM,OAAO,GAAG,KAAK;iBACnB,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,oBAAoB,CAAC,YAAY,CAAC;iBAC/C,IAAI,CAAC,IAAI,CAAC,CAAC;YACb,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAS;YAE1C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CACvB,CAAC,GAAG,oBAAoB,CAAC,YAAY,EACrC,KAAK,CAAC,MAAM,CACZ,CAAC;YACF,MAAM,CAAC,IAAI,CACV,IAAI,KAAK,CAAC;gBACT,QAAQ,EAAE,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;gBACpD,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE;gBACjC,OAAO;gBACP,OAAO,EAAE,UAAU,QAAQ,GAAG;gBAC9B,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC;aAC7B,CAAC,CACF,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { Chunk } from "../../domain/corpus/Chunk.js";
2
+ import type { ChunkerPort } from "../../domain/ports/ChunkerPort.js";
3
+ import { ChunkContextBuilder } from "./ChunkContextBuilder.js";
4
+ import { LanguageCatalog } from "./LanguageCatalog.js";
5
+ import { SlidingWindowChunker } from "./SlidingWindowChunker.js";
6
+ /**
7
+ * Splits source into chunks along AST boundaries.
8
+ *
9
+ * Node-bounded chunks are what make results readable: a hit is a whole
10
+ * function or class, not an arbitrary window through the middle of one. Files
11
+ * with no grammar, or no chunkable structure, fall back to a sliding window.
12
+ */
13
+ export declare class TreeSitterChunker implements ChunkerPort {
14
+ private readonly catalog;
15
+ private readonly context;
16
+ private readonly fallback;
17
+ /** Chunks larger than this are split by recursing into their children. */
18
+ private static readonly MAX_CHUNK_TOKENS;
19
+ /** A one-line fragment shorter than this is noise, not a unit of code. */
20
+ private static readonly MIN_CHUNK_CHARS;
21
+ private parser;
22
+ private readonly loaded;
23
+ constructor(catalog?: LanguageCatalog, context?: ChunkContextBuilder, fallback?: SlidingWindowChunker);
24
+ chunk(filePath: string, cwd: string): Promise<Chunk[]>;
25
+ /**
26
+ * Markdown needs its own pass: the block grammar nests `section` nodes by
27
+ * heading level, so emitting them whole would collapse a document into one
28
+ * chunk. Splitting at every heading the grammar reports (so a `#` inside a
29
+ * fenced code block is not mistaken for one) gives complete,
30
+ * non-overlapping, heading-granular chunks instead.
31
+ */
32
+ private chunkMarkdown;
33
+ private collect;
34
+ private hasChunkableDescendants;
35
+ private nodeName;
36
+ private getParser;
37
+ /**
38
+ * Grammars are cached for the process lifetime. They are wasm modules whose
39
+ * linear memory only ever grows, so loading one repeatedly would leak.
40
+ */
41
+ private loadGrammar;
42
+ }