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,99 @@
1
+ import { existsSync } from "node:fs";
2
+ import { SearchCriteria } from "./search/SearchCriteria.js";
3
+ /**
4
+ * The application façade: one object exposing every operation the CLI, the MCP
5
+ * server and the Pi extension need.
6
+ *
7
+ * It holds no logic of its own — each method delegates to the service that
8
+ * owns that behaviour. Its job is to be the single place where a caller
9
+ * acquires a working, wired-up lmgrep, so no entry point has to know the
10
+ * assembly order.
11
+ */
12
+ export class Lmgrep {
13
+ services;
14
+ constructor(services) {
15
+ this.services = services;
16
+ }
17
+ get cwd() {
18
+ return this.services.cwd;
19
+ }
20
+ get config() {
21
+ return this.services.config;
22
+ }
23
+ get location() {
24
+ return this.services.location;
25
+ }
26
+ build(options = {}) {
27
+ return this.services.builder.build(options);
28
+ }
29
+ search(query, options = {}) {
30
+ return this.services.searcher.search(query, new SearchCriteria(options));
31
+ }
32
+ ask(question, onTrace) {
33
+ return this.services.researcher.research(question, onTrace);
34
+ }
35
+ status() {
36
+ return this.services.statusReporter.status();
37
+ }
38
+ /** Start watching; returns a function that stops it. */
39
+ watch() {
40
+ return this.services.watcher.start();
41
+ }
42
+ /** The current branch's file manifest, for change previews. */
43
+ currentManifest() {
44
+ return this.services.manifest.current();
45
+ }
46
+ /**
47
+ * Everything the index needs done to it that is not indexing: drop dead
48
+ * branches' manifests, remove duplicate and superseded rows, compact the
49
+ * fragments, and train the vector index if the table has grown into
50
+ * wanting one.
51
+ *
52
+ * These were three separate commands. They are one call because they are
53
+ * one intent and because the order between them is not optional: `dedupe`
54
+ * keeps any chunk version some manifest still references, so sweeping dead
55
+ * branches has to happen first or their leftover rows shield their own
56
+ * orphaned chunks from collection.
57
+ */
58
+ async tidy() {
59
+ await this.services.sweeper.sweep(this.services.location.root);
60
+ const deduped = await this.services.maintenance.dedupe();
61
+ const optimized = await this.services.maintenance.compact();
62
+ return { deduped, optimized };
63
+ }
64
+ get maintenance() {
65
+ return this.services.maintenance;
66
+ }
67
+ /** Every index this machine knows about. */
68
+ get registry() {
69
+ return this.services.registry;
70
+ }
71
+ /** This project's indexes under other embedding models. */
72
+ get alternatives() {
73
+ return this.services.alternatives;
74
+ }
75
+ get projectId() {
76
+ return this.services.projectId();
77
+ }
78
+ /**
79
+ * Whether this working directory has a usable index.
80
+ *
81
+ * An indexed ancestor counts: running from a subdirectory of an indexed
82
+ * tree is ordinary, and reporting it as unindexed would disable search for
83
+ * no reason. A manually targeted database is flat, so only its own path
84
+ * matters.
85
+ */
86
+ isIndexed() {
87
+ if (this.services.location.manual) {
88
+ return existsSync(this.services.location.path);
89
+ }
90
+ if (this.services.locator.findIndexedAncestor(this.services.cwd)) {
91
+ return true;
92
+ }
93
+ return existsSync(this.services.location.path);
94
+ }
95
+ async close() {
96
+ this.services.tables.close();
97
+ }
98
+ }
99
+ //# sourceMappingURL=Lmgrep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Lmgrep.js","sourceRoot":"","sources":["../../src/application/Lmgrep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAkCrC,OAAO,EAAE,cAAc,EAAsB,MAAM,4BAA4B,CAAC;AAkChF;;;;;;;;GAQG;AACH,MAAM,OAAO,MAAM;IACW;IAA7B,YAA6B,QAAwB;QAAxB,aAAQ,GAAR,QAAQ,CAAgB;IAAG,CAAC;IAEzD,IAAI,GAAG;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,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IAED,4CAA4C;IAC5C,IAAI,QAAQ;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED,2DAA2D;IAC3D,IAAI,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;IACnC,CAAC;IAED,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;IAClC,CAAC;IAED;;;;;;;OAOG;IACH,SAAS;QACR,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACnC,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAClE,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,KAAK;QACV,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACD"}
@@ -0,0 +1,40 @@
1
+ import type { LmgrepConfig } from "../domain/config/LmgrepConfig.js";
2
+ import type { ChunkerPort } from "../domain/ports/ChunkerPort.js";
3
+ import type { EmbedderPort } from "../domain/ports/EmbedderPort.js";
4
+ import type { LoggerPort } from "../domain/ports/LoggerPort.js";
5
+ import { Lmgrep } from "./Lmgrep.js";
6
+ export interface LmgrepOptions {
7
+ cwd: string;
8
+ /**
9
+ * Target a specific database instead of the git-aware default. A bare name
10
+ * creates an independent index; a path points at a database directory.
11
+ */
12
+ database?: string;
13
+ config?: Partial<LmgrepConfig>;
14
+ embedder?: EmbedderPort;
15
+ chunker?: ChunkerPort;
16
+ logger?: LoggerPort;
17
+ /**
18
+ * Where configuration problems go. Separate from the logger because these
19
+ * are reported before anything is wired, and because the MCP server must
20
+ * silence them — stdout is its transport.
21
+ */
22
+ onWarning?: (message: string) => void;
23
+ }
24
+ /**
25
+ * Assembles a working {@link Lmgrep}.
26
+ *
27
+ * This is the only place that knows the full object graph. Everything else
28
+ * receives its collaborators, which is what keeps the layers testable and the
29
+ * dependency direction one-way.
30
+ */
31
+ export declare class LmgrepFactory {
32
+ open(options: LmgrepOptions): Promise<Lmgrep>;
33
+ /**
34
+ * Opens another project's database read-only for cross-project search.
35
+ *
36
+ * Foreign indexes get their own connection and are closed after the query,
37
+ * so a `--across` over many projects does not leave native runtimes open.
38
+ */
39
+ private foreignOpener;
40
+ }
@@ -0,0 +1,155 @@
1
+ import { ModelIdentity } from "../domain/project/ModelIdentity.js";
2
+ import { ProjectLocator } from "../domain/project/ProjectLocator.js";
3
+ import { AiSdkChatModel } from "../infrastructure/ai/AiSdkChatModel.js";
4
+ import { AiSdkEmbedder } from "../infrastructure/ai/AiSdkEmbedder.js";
5
+ import { LocalModelReloader } from "../infrastructure/ai/LocalModelReloader.js";
6
+ import { ConfigLoader } from "../infrastructure/fs/ConfigLoader.js";
7
+ import { DatabaseLocks } from "../infrastructure/fs/DatabaseLocks.js";
8
+ import { ConsoleLogger } from "../infrastructure/fs/Loggers.js";
9
+ import { ProjectIndexes } from "../infrastructure/fs/ProjectIndexes.js";
10
+ import { ProjectMetadataStore } from "../infrastructure/fs/ProjectMetadataStore.js";
11
+ import { ProjectRegistry } from "../infrastructure/fs/ProjectRegistry.js";
12
+ import { StateDirectory } from "../infrastructure/fs/StateDirectory.js";
13
+ import { Workspace } from "../infrastructure/fs/Workspace.js";
14
+ import { GitClient } from "../infrastructure/git/GitClient.js";
15
+ import { ChunkRepository } from "../infrastructure/lancedb/ChunkRepository.js";
16
+ import { FileManifestRepository } from "../infrastructure/lancedb/FileManifestRepository.js";
17
+ import { IndexMaintenance } from "../infrastructure/lancedb/IndexMaintenance.js";
18
+ import { LanceTables } from "../infrastructure/lancedb/LanceTables.js";
19
+ import { TreeSitterChunker } from "../infrastructure/treesitter/TreeSitterChunker.js";
20
+ import { BranchBootstrapper } from "./indexing/BranchBootstrapper.js";
21
+ import { BranchManifestSweeper } from "./indexing/BranchManifestSweeper.js";
22
+ import { IndexBuilder } from "./indexing/IndexBuilder.js";
23
+ import { Lmgrep } from "./Lmgrep.js";
24
+ import { IndexAlternatives } from "./operations/IndexAlternatives.js";
25
+ import { StatusService } from "./operations/StatusService.js";
26
+ import { WatchService } from "./operations/WatchService.js";
27
+ import { ResearchAgent } from "./research/ResearchAgent.js";
28
+ import { SearchService } from "./search/SearchService.js";
29
+ import { SearchTargetResolver, } from "./search/SearchTargetResolver.js";
30
+ /**
31
+ * Assembles a working {@link Lmgrep}.
32
+ *
33
+ * This is the only place that knows the full object graph. Everything else
34
+ * receives its collaborators, which is what keeps the layers testable and the
35
+ * dependency direction one-way.
36
+ */
37
+ export class LmgrepFactory {
38
+ async open(options) {
39
+ const { cwd } = options;
40
+ const logger = options.logger ?? new ConsoleLogger();
41
+ const loader = new ConfigLoader();
42
+ const config = {
43
+ ...loader.load(cwd),
44
+ ...options.config,
45
+ };
46
+ for (const warning of loader.warnings)
47
+ options.onWarning?.(warning);
48
+ const state = new StateDirectory();
49
+ const git = new GitClient();
50
+ // The model partitions the databases, so it has to be known before a
51
+ // location can be resolved — which is why config loads first.
52
+ const locator = new ProjectLocator(git, state, ModelIdentity.of(config.model), config.dimensions);
53
+ const location = locator.resolveDatabase(cwd, options.database);
54
+ const metadata = new ProjectMetadataStore();
55
+ const registry = new ProjectRegistry(state);
56
+ const alternatives = new IndexAlternatives(new ProjectIndexes(metadata), locator, location, config, cwd);
57
+ const locks = new DatabaseLocks(state.locksDirectory(), location.path, location.root);
58
+ const tables = new LanceTables(location.path, location.branch);
59
+ const manifest = new FileManifestRepository(tables, location.branch);
60
+ const chunks = new ChunkRepository(tables, manifest, location.branch);
61
+ const maintenance = new IndexMaintenance(tables, manifest);
62
+ const embedder = options.embedder ?? new AiSdkEmbedder(config);
63
+ const chunker = options.chunker ?? new TreeSitterChunker();
64
+ const workspace = new Workspace();
65
+ const reloader = new LocalModelReloader(config);
66
+ const sweeper = new BranchManifestSweeper(manifest, git, logger);
67
+ const builder = new IndexBuilder({
68
+ workspace,
69
+ chunker,
70
+ embedder,
71
+ chunks,
72
+ manifest,
73
+ maintenance,
74
+ bootstrapper: new BranchBootstrapper(manifest, git, logger),
75
+ sweeper,
76
+ logger,
77
+ config,
78
+ location,
79
+ locks,
80
+ recordMetadata: (dimensions) => {
81
+ const project = locator.resolveProject(cwd);
82
+ metadata.write(location.path, {
83
+ root: project.root,
84
+ remote: project.remote,
85
+ branch: location.branch.toString(),
86
+ model: config.model,
87
+ dimensions,
88
+ });
89
+ },
90
+ // The sidecar says what this database is; the registry says that
91
+ // it exists. Nothing walks the filesystem looking for databases
92
+ // now that they live inside repositories, so an index that is
93
+ // never registered is one `lmgrep projects` and cross-project
94
+ // search cannot see.
95
+ registerIndex: () => {
96
+ const project = locator.resolveProject(cwd);
97
+ registry.record({
98
+ root: locator.projectRootFor(cwd),
99
+ name: location.manual ? options.database : undefined,
100
+ remote: project.remote,
101
+ databasePath: location.path,
102
+ model: config.model,
103
+ dimensions: metadata.read(location.path)?.dimensions,
104
+ });
105
+ },
106
+ reloadModel: () => reloader.reload(),
107
+ isLocalProvider: reloader.isLocal,
108
+ });
109
+ const searcher = new SearchService(embedder, new SearchTargetResolver(cwd, chunks, location, locator, this.foreignOpener(locator)), config, logger, () => metadata.read(location.path), alternatives);
110
+ const services = {
111
+ cwd,
112
+ config,
113
+ location,
114
+ locator,
115
+ logger,
116
+ tables,
117
+ chunks,
118
+ manifest,
119
+ maintenance,
120
+ metadata,
121
+ registry,
122
+ alternatives,
123
+ embedder,
124
+ chunker,
125
+ builder,
126
+ sweeper,
127
+ searcher,
128
+ statusReporter: new StatusService(chunks, maintenance, embedder, locator, metadata, location, config, cwd, loader.sources, alternatives),
129
+ watcher: new WatchService(builder, workspace, config, cwd, logger, locks),
130
+ researcher: new ResearchAgent(searcher, new AiSdkChatModel(config), config),
131
+ projectId: () => locator.resolveProject(cwd).id,
132
+ };
133
+ return new Lmgrep(services);
134
+ }
135
+ /**
136
+ * Opens another project's database read-only for cross-project search.
137
+ *
138
+ * Foreign indexes get their own connection and are closed after the query,
139
+ * so a `--across` over many projects does not leave native runtimes open.
140
+ */
141
+ foreignOpener(locator) {
142
+ return {
143
+ async open(projectPath) {
144
+ const project = locator.resolveProject(projectPath);
145
+ const tables = new LanceTables(locator.databasePathFor(projectPath), project.branch);
146
+ const manifest = new FileManifestRepository(tables, project.branch);
147
+ return {
148
+ chunks: new ChunkRepository(tables, manifest, project.branch),
149
+ close: async () => tables.close(),
150
+ };
151
+ },
152
+ };
153
+ }
154
+ }
155
+ //# sourceMappingURL=LmgrepFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LmgrepFactory.js","sourceRoot":"","sources":["../../src/application/LmgrepFactory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,c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,EAAE,MAAM,EAAE,KAAK,CAAC;YACzE,UAAU,EAAE,IAAI,aAAa,CAC5B,QAAQ,EACR,IAAI,cAAc,CAAC,MAAM,CAAC,EAC1B,MAAM,CACN;YACD,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE;SAC/C,CAAC;QAEF,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACK,aAAa,CAAC,OAAuB;QAC5C,OAAO;YACN,KAAK,CAAC,IAAI,CAAC,WAAmB;gBAC7B,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;gBACpD,MAAM,MAAM,GAAG,IAAI,WAAW,CAC7B,OAAO,CAAC,eAAe,CAAC,WAAW,CAAC,EACpC,OAAO,CAAC,MAAM,CACd,CAAC;gBACF,MAAM,QAAQ,GAAG,IAAI,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;gBACpE,OAAO;oBACN,MAAM,EAAE,IAAI,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC;oBAC7D,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;iBACjC,CAAC;YACH,CAAC;SACD,CAAC;IACH,CAAC;CACD"}
@@ -0,0 +1,21 @@
1
+ import type { FileManifestRepositoryPort } from "../../domain/ports/FileManifestRepositoryPort.js";
2
+ import type { GitPort } from "../../domain/ports/GitPort.js";
3
+ import type { LoggerPort } from "../../domain/ports/LoggerPort.js";
4
+ /**
5
+ * Seeds a new branch's manifest from its closest relative.
6
+ *
7
+ * Checking out a branch would otherwise present as "nothing indexed" and
8
+ * trigger a full re-embed of the whole tree, even though almost every file is
9
+ * byte-identical to the branch it came from. Copying the nearest branch's
10
+ * manifest turns that into a diff of the handful of files that actually differ.
11
+ */
12
+ export declare class BranchBootstrapper {
13
+ private readonly manifest;
14
+ private readonly git;
15
+ private readonly logger;
16
+ constructor(manifest: FileManifestRepositoryPort, git: GitPort, logger: LoggerPort);
17
+ /** No-op unless this branch's manifest is empty. */
18
+ bootstrap(repoRoot: string): Promise<void>;
19
+ /** The stored branch fewest commits behind HEAD. */
20
+ private closestBranch;
21
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Seeds a new branch's manifest from its closest relative.
3
+ *
4
+ * Checking out a branch would otherwise present as "nothing indexed" and
5
+ * trigger a full re-embed of the whole tree, even though almost every file is
6
+ * byte-identical to the branch it came from. Copying the nearest branch's
7
+ * manifest turns that into a diff of the handful of files that actually differ.
8
+ */
9
+ export class BranchBootstrapper {
10
+ manifest;
11
+ git;
12
+ logger;
13
+ constructor(manifest, git, logger) {
14
+ this.manifest = manifest;
15
+ this.git = git;
16
+ this.logger = logger;
17
+ }
18
+ /** No-op unless this branch's manifest is empty. */
19
+ async bootstrap(repoRoot) {
20
+ if (!(await this.manifest.current()).isEmpty)
21
+ return;
22
+ const stored = await this.manifest.storedBranches();
23
+ if (stored.length === 0)
24
+ return;
25
+ const source = this.closestBranch(repoRoot, stored);
26
+ if (!source)
27
+ return;
28
+ const copied = await this.manifest.copyFromBranch(source);
29
+ if (copied > 0) {
30
+ this.logger.info(`Bootstrapped from "${source}" manifest (${copied} files). Diffing changes...`);
31
+ }
32
+ }
33
+ /** The stored branch fewest commits behind HEAD. */
34
+ closestBranch(repoRoot, candidates) {
35
+ let best;
36
+ let bestDistance = Number.POSITIVE_INFINITY;
37
+ for (const candidate of candidates) {
38
+ const mergeBase = this.git.mergeBase(repoRoot, candidate);
39
+ if (!mergeBase)
40
+ continue;
41
+ const distance = this.git.commitDistance(repoRoot, mergeBase, "HEAD");
42
+ if (distance === undefined)
43
+ continue;
44
+ if (distance < bestDistance) {
45
+ bestDistance = distance;
46
+ best = candidate;
47
+ }
48
+ }
49
+ return best;
50
+ }
51
+ }
52
+ //# sourceMappingURL=BranchBootstrapper.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C;YAC1D,IAAI,CAAC,SAAS;gBAAE,SAAS;YACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YACtE,IAAI,QAAQ,KAAK,SAAS;gBAAE,SAAS;YACrC,IAAI,QAAQ,GAAG,YAAY,EAAE,CAAC;gBAC7B,YAAY,GAAG,QAAQ,CAAC;gBACxB,IAAI,GAAG,SAAS,CAAC;YAClB,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
@@ -0,0 +1,17 @@
1
+ import type { FileManifestRepositoryPort } from "../../domain/ports/FileManifestRepositoryPort.js";
2
+ import type { GitPort } from "../../domain/ports/GitPort.js";
3
+ import type { LoggerPort } from "../../domain/ports/LoggerPort.js";
4
+ /**
5
+ * Drops manifests for branches git no longer has.
6
+ *
7
+ * Without this, every deleted feature branch leaves its file manifest behind
8
+ * forever, and those rows keep chunks alive that nothing can reach — the index
9
+ * grows monotonically across a project's lifetime.
10
+ */
11
+ export declare class BranchManifestSweeper {
12
+ private readonly manifest;
13
+ private readonly git;
14
+ private readonly logger;
15
+ constructor(manifest: FileManifestRepositoryPort, git: GitPort, logger: LoggerPort);
16
+ sweep(repoRoot: string): Promise<void>;
17
+ }
@@ -0,0 +1,35 @@
1
+ import { Branch } from "../../domain/project/Branch.js";
2
+ /**
3
+ * Drops manifests for branches git no longer has.
4
+ *
5
+ * Without this, every deleted feature branch leaves its file manifest behind
6
+ * forever, and those rows keep chunks alive that nothing can reach — the index
7
+ * grows monotonically across a project's lifetime.
8
+ */
9
+ export class BranchManifestSweeper {
10
+ manifest;
11
+ git;
12
+ logger;
13
+ constructor(manifest, git, logger) {
14
+ this.manifest = manifest;
15
+ this.git = git;
16
+ this.logger = logger;
17
+ }
18
+ async sweep(repoRoot) {
19
+ const branches = this.git.localBranches(repoRoot);
20
+ // No git, or an unreadable repo: nothing can be proven stale, so leave
21
+ // every manifest alone rather than guessing.
22
+ if (branches.length === 0)
23
+ return;
24
+ const live = new Set(branches);
25
+ // Non-git projects index under the default branch, which git never lists.
26
+ live.add(Branch.DEFAULT_NAME);
27
+ for (const stored of await this.manifest.storedBranches()) {
28
+ if (live.has(stored))
29
+ continue;
30
+ await this.manifest.deleteBranch(stored);
31
+ this.logger.info(`Swept stale manifest for deleted branch "${stored}"`);
32
+ }
33
+ }
34
+ }
35
+ //# sourceMappingURL=BranchManifestSweeper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BranchManifestSweeper.js","sourceRoot":"","sources":["../../../src/application/indexing/BranchManifestSweeper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,OAAO,qBAAqB;IAEf;IACA;IACA;IAHlB,YACkB,QAAoC,EACpC,GAAY,EACZ,MAAkB;QAFlB,aAAQ,GAAR,QAAQ,CAA4B;QACpC,QAAG,GAAH,GAAG,CAAS;QACZ,WAAM,GAAN,MAAM,CAAY;IACjC,CAAC;IAEJ,KAAK,CAAC,KAAK,CAAC,QAAgB;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAClD,uEAAuE;QACvE,6CAA6C;QAC7C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAElC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/B,0EAA0E;QAC1E,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAE9B,KAAK,MAAM,MAAM,IAAI,MAAM,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAE,CAAC;YAC3D,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;gBAAE,SAAS;YAC/B,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,4CAA4C,MAAM,GAAG,CAAC,CAAC;QACzE,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,9 @@
1
+ /** A human-written duration like "10m" or "2h", as milliseconds. */
2
+ export declare class Duration {
3
+ readonly milliseconds: number;
4
+ private static readonly UNIT_MS;
5
+ private constructor();
6
+ static parse(value: string): Duration;
7
+ /** The wall-clock instant this duration ago. */
8
+ agoFrom(now: number): number;
9
+ }
@@ -0,0 +1,25 @@
1
+ /** A human-written duration like "10m" or "2h", as milliseconds. */
2
+ export class Duration {
3
+ milliseconds;
4
+ static UNIT_MS = {
5
+ s: 1000,
6
+ m: 60_000,
7
+ h: 3_600_000,
8
+ d: 86_400_000,
9
+ };
10
+ constructor(milliseconds) {
11
+ this.milliseconds = milliseconds;
12
+ }
13
+ static parse(value) {
14
+ const match = value.match(/^(\d+)\s*(s|m|h|d)$/);
15
+ if (!match) {
16
+ throw new Error(`Invalid duration "${value}". Use e.g. 10m, 2h, 1d`);
17
+ }
18
+ return new Duration(Number.parseInt(match[1], 10) * Duration.UNIT_MS[match[2]]);
19
+ }
20
+ /** The wall-clock instant this duration ago. */
21
+ agoFrom(now) {
22
+ return now - this.milliseconds;
23
+ }
24
+ }
25
+ //# sourceMappingURL=Duration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Duration.js","sourceRoot":"","sources":["../../../src/application/indexing/Duration.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,OAAO,QAAQ;IAQS;IAPrB,MAAM,CAAU,OAAO,GAA2B;QACzD,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,MAAM;QACT,CAAC,EAAE,SAAS;QACZ,CAAC,EAAE,UAAU;KACb,CAAC;IAEF,YAA6B,YAAoB;QAApB,iBAAY,GAAZ,YAAY,CAAQ;IAAG,CAAC;IAErD,MAAM,CAAC,KAAK,CAAC,KAAa;QACzB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,yBAAyB,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,IAAI,QAAQ,CAClB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAC1D,CAAC;IACH,CAAC;IAED,gDAAgD;IAChD,OAAO,CAAC,GAAW;QAClB,OAAO,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC;IAChC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Raised when too many consecutive batches fail — the provider is down rather
3
+ * than the input being bad. Successes are already persisted by the time this
4
+ * throws, so the caller's job is to report and exit, not to roll back.
5
+ */
6
+ export declare class EmbeddingAbortError extends Error {
7
+ readonly succeeded: number;
8
+ readonly failedIndices: Set<number>;
9
+ readonly total: number;
10
+ constructor(succeeded: number, failedIndices: Set<number>, total: number);
11
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Raised when too many consecutive batches fail — the provider is down rather
3
+ * than the input being bad. Successes are already persisted by the time this
4
+ * throws, so the caller's job is to report and exit, not to roll back.
5
+ */
6
+ export class EmbeddingAbortError extends Error {
7
+ succeeded;
8
+ failedIndices;
9
+ total;
10
+ constructor(succeeded, failedIndices, total) {
11
+ super(`Embedding aborted after ${failedIndices.size} failures. ` +
12
+ `${succeeded}/${total} chunks embedded successfully. ` +
13
+ "Check your embedding provider and run `lmgrep index` to resume.");
14
+ this.succeeded = succeeded;
15
+ this.failedIndices = failedIndices;
16
+ this.total = total;
17
+ this.name = "EmbeddingAbortError";
18
+ }
19
+ }
20
+ //# sourceMappingURL=EmbeddingAbortError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmbeddingAbortError.js","sourceRoot":"","sources":["../../../src/application/indexing/EmbeddingAbortError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAEnC;IACA;IACA;IAHV,YACU,SAAiB,EACjB,aAA0B,EAC1B,KAAa;QAEtB,KAAK,CACJ,2BAA2B,aAAa,CAAC,IAAI,aAAa;YACzD,GAAG,SAAS,IAAI,KAAK,iCAAiC;YACtD,iEAAiE,CAClE,CAAC;QARO,cAAS,GAAT,SAAS,CAAQ;QACjB,kBAAa,GAAb,aAAa,CAAa;QAC1B,UAAK,GAAL,KAAK,CAAQ;QAOtB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACnC,CAAC;CACD"}
@@ -0,0 +1,59 @@
1
+ import type { LmgrepConfig } from "../../domain/config/LmgrepConfig.js";
2
+ import type { Vector } from "../../domain/corpus/Vector.js";
3
+ import type { EmbedderPort } from "../../domain/ports/EmbedderPort.js";
4
+ /** One successfully embedded item, keyed by its position in the input. */
5
+ export interface EmbeddedItem {
6
+ index: number;
7
+ vector: Vector;
8
+ }
9
+ export interface EmbeddingProgress {
10
+ onBatchStart?(batchNumber: number, totalBatches: number): void;
11
+ onBatchDone?(batchNumber: number, succeeded: number, failed: number): void;
12
+ onReload?(attempt: number, max: number): void;
13
+ }
14
+ /**
15
+ * Embeds a list of texts batch by batch, surviving a flaky provider.
16
+ *
17
+ * Three behaviours matter here and are easy to lose:
18
+ *
19
+ * - **Incremental persistence.** Each batch is handed to `persist` before the
20
+ * next starts, so a crash leaves completed work in the index and a resume
21
+ * skips it. Nothing is buffered for the caller to write at the end.
22
+ * - **Per-item retry.** A failed batch is retried one item at a time, so a
23
+ * single oversized chunk cannot cost the other 99 in its batch.
24
+ * - **Model reload.** A local provider that has fallen over is given a chance
25
+ * to reload, and the failed span is replayed rather than abandoned.
26
+ */
27
+ export declare class EmbeddingPipeline {
28
+ private readonly embedder;
29
+ private readonly config;
30
+ private readonly progress;
31
+ /** Reloads a local model; returns false when it cannot be done. */
32
+ private readonly reloadModel;
33
+ /** Whether the provider is local, and therefore reloadable. */
34
+ private readonly isLocal;
35
+ private static readonly BATCH_DELAY_MS;
36
+ private static readonly MAX_CONSECUTIVE_FAILURES;
37
+ private static readonly MAX_RELOADS;
38
+ private consecutiveFailures;
39
+ private reloads;
40
+ constructor(embedder: EmbedderPort, config: LmgrepConfig, progress?: EmbeddingProgress,
41
+ /** Reloads a local model; returns false when it cannot be done. */
42
+ reloadModel?: () => Promise<boolean>,
43
+ /** Whether the provider is local, and therefore reloadable. */
44
+ isLocal?: boolean);
45
+ /**
46
+ * Returns the positions that could not be embedded. Successes are reported
47
+ * through `persist` exactly once each, never returned in bulk.
48
+ */
49
+ run(texts: string[], persist: (items: EmbeddedItem[]) => Promise<void>): Promise<{
50
+ failedIndices: Set<number>;
51
+ }>;
52
+ /** Retry a failed batch item by item; returns how many still failed. */
53
+ private retryIndividually;
54
+ /**
55
+ * Give a local model a chance to come back, and return the loop position to
56
+ * rewind to. Undefined means give up.
57
+ */
58
+ private tryReload;
59
+ }