lmgrep 0.1.18 → 0.2.1

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 (414) hide show
  1. package/README.md +253 -62
  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 +4 -953
  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 +94 -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 -45
  178. package/dist/index.js +30 -567
  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/DockerModelRunnerProbe.d.ts +16 -0
  187. package/dist/infrastructure/ai/DockerModelRunnerProbe.js +52 -0
  188. package/dist/infrastructure/ai/DockerModelRunnerProbe.js.map +1 -0
  189. package/dist/infrastructure/ai/EmbeddingPrefixes.d.ts +21 -0
  190. package/dist/infrastructure/ai/EmbeddingPrefixes.js +40 -0
  191. package/dist/infrastructure/ai/EmbeddingPrefixes.js.map +1 -0
  192. package/dist/infrastructure/ai/LmStudioProbe.d.ts +18 -0
  193. package/dist/infrastructure/ai/LmStudioProbe.js +49 -0
  194. package/dist/infrastructure/ai/LmStudioProbe.js.map +1 -0
  195. package/dist/infrastructure/ai/LocalModelReloader.d.ts +21 -0
  196. package/dist/infrastructure/ai/LocalModelReloader.js +61 -0
  197. package/dist/infrastructure/ai/LocalModelReloader.js.map +1 -0
  198. package/dist/infrastructure/ai/LocalRuntimeDetector.d.ts +36 -0
  199. package/dist/infrastructure/ai/LocalRuntimeDetector.js +63 -0
  200. package/dist/infrastructure/ai/LocalRuntimeDetector.js.map +1 -0
  201. package/dist/infrastructure/ai/ModelRuntime.d.ts +32 -0
  202. package/dist/infrastructure/ai/ModelRuntime.js +2 -0
  203. package/dist/infrastructure/ai/ModelRuntime.js.map +1 -0
  204. package/dist/infrastructure/ai/OllamaProbe.d.ts +22 -0
  205. package/dist/infrastructure/ai/OllamaProbe.js +71 -0
  206. package/dist/infrastructure/ai/OllamaProbe.js.map +1 -0
  207. package/dist/infrastructure/ai/ProviderFailure.d.ts +16 -0
  208. package/dist/infrastructure/ai/ProviderFailure.js +35 -0
  209. package/dist/infrastructure/ai/ProviderFailure.js.map +1 -0
  210. package/dist/infrastructure/ai/ProviderModuleLoader.d.ts +14 -0
  211. package/dist/infrastructure/ai/ProviderModuleLoader.js +56 -0
  212. package/dist/infrastructure/ai/ProviderModuleLoader.js.map +1 -0
  213. package/dist/infrastructure/ai/ProviderRegistry.d.ts +38 -0
  214. package/dist/infrastructure/ai/ProviderRegistry.js +63 -0
  215. package/dist/infrastructure/ai/ProviderRegistry.js.map +1 -0
  216. package/dist/infrastructure/fs/ConfigLoader.d.ts +59 -0
  217. package/dist/infrastructure/fs/ConfigLoader.js +194 -0
  218. package/dist/infrastructure/fs/ConfigLoader.js.map +1 -0
  219. package/dist/infrastructure/fs/DatabaseLocks.d.ts +52 -0
  220. package/dist/infrastructure/fs/DatabaseLocks.js +92 -0
  221. package/dist/infrastructure/fs/DatabaseLocks.js.map +1 -0
  222. package/dist/infrastructure/fs/DiskUsage.d.ts +6 -0
  223. package/dist/infrastructure/fs/DiskUsage.js +41 -0
  224. package/dist/infrastructure/fs/DiskUsage.js.map +1 -0
  225. package/dist/infrastructure/fs/IndexableFileRules.d.ts +33 -0
  226. package/dist/infrastructure/fs/IndexableFileRules.js +177 -0
  227. package/dist/infrastructure/fs/IndexableFileRules.js.map +1 -0
  228. package/dist/infrastructure/fs/Loggers.d.ts +14 -0
  229. package/dist/infrastructure/fs/Loggers.js +18 -0
  230. package/dist/infrastructure/fs/Loggers.js.map +1 -0
  231. package/dist/infrastructure/fs/PidFileLock.d.ts +40 -0
  232. package/dist/infrastructure/fs/PidFileLock.js +97 -0
  233. package/dist/infrastructure/fs/PidFileLock.js.map +1 -0
  234. package/dist/infrastructure/fs/ProjectIndexes.d.ts +8 -0
  235. package/dist/infrastructure/fs/ProjectIndexes.js +35 -0
  236. package/dist/infrastructure/fs/ProjectIndexes.js.map +1 -0
  237. package/dist/infrastructure/fs/ProjectMetadataStore.d.ts +42 -0
  238. package/dist/infrastructure/fs/ProjectMetadataStore.js +86 -0
  239. package/dist/infrastructure/fs/ProjectMetadataStore.js.map +1 -0
  240. package/dist/infrastructure/fs/ProjectRegistry.d.ts +25 -0
  241. package/dist/infrastructure/fs/ProjectRegistry.js +83 -0
  242. package/dist/infrastructure/fs/ProjectRegistry.js.map +1 -0
  243. package/dist/infrastructure/fs/StateDirectory.d.ts +28 -0
  244. package/dist/infrastructure/fs/StateDirectory.js +71 -0
  245. package/dist/infrastructure/fs/StateDirectory.js.map +1 -0
  246. package/dist/infrastructure/fs/Workspace.d.ts +25 -0
  247. package/dist/infrastructure/fs/Workspace.js +90 -0
  248. package/dist/infrastructure/fs/Workspace.js.map +1 -0
  249. package/dist/infrastructure/git/GitClient.d.ts +34 -0
  250. package/dist/infrastructure/git/GitClient.js +74 -0
  251. package/dist/infrastructure/git/GitClient.js.map +1 -0
  252. package/dist/infrastructure/lancedb/ChunkRepository.d.ts +38 -0
  253. package/dist/infrastructure/lancedb/ChunkRepository.js +166 -0
  254. package/dist/infrastructure/lancedb/ChunkRepository.js.map +1 -0
  255. package/dist/infrastructure/lancedb/DatabaseImporter.d.ts +22 -0
  256. package/dist/infrastructure/lancedb/DatabaseImporter.js +74 -0
  257. package/dist/infrastructure/lancedb/DatabaseImporter.js.map +1 -0
  258. package/dist/infrastructure/lancedb/FileManifestRepository.d.ts +34 -0
  259. package/dist/infrastructure/lancedb/FileManifestRepository.js +137 -0
  260. package/dist/infrastructure/lancedb/FileManifestRepository.js.map +1 -0
  261. package/dist/infrastructure/lancedb/IndexMaintenance.d.ts +53 -0
  262. package/dist/infrastructure/lancedb/IndexMaintenance.js +227 -0
  263. package/dist/infrastructure/lancedb/IndexMaintenance.js.map +1 -0
  264. package/dist/infrastructure/lancedb/LanceTables.d.ts +67 -0
  265. package/dist/infrastructure/lancedb/LanceTables.js +159 -0
  266. package/dist/infrastructure/lancedb/LanceTables.js.map +1 -0
  267. package/dist/{lib/native-tuning.js → infrastructure/lancedb/NativeTuning.js} +1 -1
  268. package/dist/infrastructure/lancedb/NativeTuning.js.map +1 -0
  269. package/dist/infrastructure/lancedb/RowReplication.d.ts +27 -0
  270. package/dist/infrastructure/lancedb/RowReplication.js +82 -0
  271. package/dist/infrastructure/lancedb/RowReplication.js.map +1 -0
  272. package/dist/infrastructure/lancedb/VectorIndexPolicy.d.ts +60 -0
  273. package/dist/infrastructure/lancedb/VectorIndexPolicy.js +72 -0
  274. package/dist/infrastructure/lancedb/VectorIndexPolicy.js.map +1 -0
  275. package/dist/infrastructure/p2p/IndexShare.d.ts +45 -0
  276. package/dist/infrastructure/p2p/IndexShare.js +160 -0
  277. package/dist/infrastructure/p2p/IndexShare.js.map +1 -0
  278. package/dist/infrastructure/p2p/PeerSwarm.d.ts +16 -0
  279. package/dist/infrastructure/p2p/PeerSwarm.js +41 -0
  280. package/dist/infrastructure/p2p/PeerSwarm.js.map +1 -0
  281. package/dist/infrastructure/p2p/SecureChannel.d.ts +60 -0
  282. package/dist/infrastructure/p2p/SecureChannel.js +71 -0
  283. package/dist/infrastructure/p2p/SecureChannel.js.map +1 -0
  284. package/dist/infrastructure/p2p/ShareCode.d.ts +25 -0
  285. package/dist/infrastructure/p2p/ShareCode.js +304 -0
  286. package/dist/infrastructure/p2p/ShareCode.js.map +1 -0
  287. package/dist/infrastructure/process/ProcessRegistry.d.ts +50 -0
  288. package/dist/infrastructure/process/ProcessRegistry.js +109 -0
  289. package/dist/infrastructure/process/ProcessRegistry.js.map +1 -0
  290. package/dist/infrastructure/treesitter/ChunkContextBuilder.d.ts +45 -0
  291. package/dist/infrastructure/treesitter/ChunkContextBuilder.js +159 -0
  292. package/dist/infrastructure/treesitter/ChunkContextBuilder.js.map +1 -0
  293. package/dist/infrastructure/treesitter/EmbeddedTreeSitterAssets.d.ts +8 -0
  294. package/dist/infrastructure/treesitter/EmbeddedTreeSitterAssets.js +12 -0
  295. package/dist/infrastructure/treesitter/EmbeddedTreeSitterAssets.js.map +1 -0
  296. package/dist/infrastructure/treesitter/LanguageCatalog.d.ts +30 -0
  297. package/dist/{lib/chunker/languages.js → infrastructure/treesitter/LanguageCatalog.js} +38 -29
  298. package/dist/infrastructure/treesitter/LanguageCatalog.js.map +1 -0
  299. package/dist/infrastructure/treesitter/SlidingWindowChunker.d.ts +15 -0
  300. package/dist/infrastructure/treesitter/SlidingWindowChunker.js +42 -0
  301. package/dist/infrastructure/treesitter/SlidingWindowChunker.js.map +1 -0
  302. package/dist/infrastructure/treesitter/TreeSitterChunker.d.ts +42 -0
  303. package/dist/infrastructure/treesitter/TreeSitterChunker.js +165 -0
  304. package/dist/infrastructure/treesitter/TreeSitterChunker.js.map +1 -0
  305. package/dist/mcp.d.ts +1 -1
  306. package/dist/mcp.js +14 -72
  307. package/dist/mcp.js.map +1 -1
  308. package/dist/presentation/cli/Cli.d.ts +31 -0
  309. package/dist/presentation/cli/Cli.js +120 -0
  310. package/dist/presentation/cli/Cli.js.map +1 -0
  311. package/dist/presentation/cli/CliOptions.d.ts +18 -0
  312. package/dist/presentation/cli/CliOptions.js +25 -0
  313. package/dist/presentation/cli/CliOptions.js.map +1 -0
  314. package/dist/presentation/cli/CommandContext.d.ts +50 -0
  315. package/dist/presentation/cli/CommandContext.js +88 -0
  316. package/dist/presentation/cli/CommandContext.js.map +1 -0
  317. package/dist/presentation/cli/ConfigTemplate.d.ts +31 -0
  318. package/dist/presentation/cli/ConfigTemplate.js +83 -0
  319. package/dist/presentation/cli/ConfigTemplate.js.map +1 -0
  320. package/dist/presentation/cli/Renderer.d.ts +90 -0
  321. package/dist/presentation/cli/Renderer.js +290 -0
  322. package/dist/presentation/cli/Renderer.js.map +1 -0
  323. package/dist/presentation/cli/commands/AskCommand.d.ts +14 -0
  324. package/dist/presentation/cli/commands/AskCommand.js +48 -0
  325. package/dist/presentation/cli/commands/AskCommand.js.map +1 -0
  326. package/dist/presentation/cli/commands/CompletionsCommand.d.ts +18 -0
  327. package/dist/presentation/cli/commands/CompletionsCommand.js +96 -0
  328. package/dist/presentation/cli/commands/CompletionsCommand.js.map +1 -0
  329. package/dist/presentation/cli/commands/ConfigCommands.d.ts +56 -0
  330. package/dist/presentation/cli/commands/ConfigCommands.js +220 -0
  331. package/dist/presentation/cli/commands/ConfigCommands.js.map +1 -0
  332. package/dist/presentation/cli/commands/IndexCommand.d.ts +18 -0
  333. package/dist/presentation/cli/commands/IndexCommand.js +54 -0
  334. package/dist/presentation/cli/commands/IndexCommand.js.map +1 -0
  335. package/dist/presentation/cli/commands/ProjectsCommand.d.ts +48 -0
  336. package/dist/presentation/cli/commands/ProjectsCommand.js +240 -0
  337. package/dist/presentation/cli/commands/ProjectsCommand.js.map +1 -0
  338. package/dist/presentation/cli/commands/SearchCommand.d.ts +19 -0
  339. package/dist/presentation/cli/commands/SearchCommand.js +55 -0
  340. package/dist/presentation/cli/commands/SearchCommand.js.map +1 -0
  341. package/dist/presentation/cli/commands/ServerCommands.d.ts +13 -0
  342. package/dist/presentation/cli/commands/ServerCommands.js +40 -0
  343. package/dist/presentation/cli/commands/ServerCommands.js.map +1 -0
  344. package/dist/presentation/cli/commands/ShareCommands.d.ts +22 -0
  345. package/dist/presentation/cli/commands/ShareCommands.js +134 -0
  346. package/dist/presentation/cli/commands/ShareCommands.js.map +1 -0
  347. package/dist/presentation/cli/commands/StatusCommand.d.ts +15 -0
  348. package/dist/presentation/cli/commands/StatusCommand.js +53 -0
  349. package/dist/presentation/cli/commands/StatusCommand.js.map +1 -0
  350. package/dist/presentation/mcp/HitFormatter.d.ts +17 -0
  351. package/dist/presentation/mcp/HitFormatter.js +42 -0
  352. package/dist/presentation/mcp/HitFormatter.js.map +1 -0
  353. package/dist/presentation/mcp/IndexWatchController.d.ts +17 -0
  354. package/dist/presentation/mcp/IndexWatchController.js +31 -0
  355. package/dist/presentation/mcp/IndexWatchController.js.map +1 -0
  356. package/dist/presentation/mcp/LmgrepCore.d.ts +66 -0
  357. package/dist/presentation/mcp/LmgrepCore.js +178 -0
  358. package/dist/presentation/mcp/LmgrepCore.js.map +1 -0
  359. package/dist/presentation/mcp/McpServer.d.ts +18 -0
  360. package/dist/presentation/mcp/McpServer.js +63 -0
  361. package/dist/presentation/mcp/McpServer.js.map +1 -0
  362. package/dist/presentation/mcp/ToolDescriptions.d.ts +40 -0
  363. package/dist/presentation/mcp/ToolDescriptions.js +85 -0
  364. package/dist/presentation/mcp/ToolDescriptions.js.map +1 -0
  365. package/package.json +93 -89
  366. package/dist/lib/build.d.ts +0 -21
  367. package/dist/lib/build.js +0 -374
  368. package/dist/lib/build.js.map +0 -1
  369. package/dist/lib/chunker/context.d.ts +0 -21
  370. package/dist/lib/chunker/context.js +0 -131
  371. package/dist/lib/chunker/context.js.map +0 -1
  372. package/dist/lib/chunker/index.d.ts +0 -7
  373. package/dist/lib/chunker/index.js +0 -209
  374. package/dist/lib/chunker/index.js.map +0 -1
  375. package/dist/lib/chunker/languages.d.ts +0 -15
  376. package/dist/lib/chunker/languages.js.map +0 -1
  377. package/dist/lib/config.d.ts +0 -12
  378. package/dist/lib/config.js +0 -83
  379. package/dist/lib/config.js.map +0 -1
  380. package/dist/lib/embedder.d.ts +0 -65
  381. package/dist/lib/embedder.js +0 -236
  382. package/dist/lib/embedder.js.map +0 -1
  383. package/dist/lib/facet-session.d.ts +0 -44
  384. package/dist/lib/facet-session.js +0 -125
  385. package/dist/lib/facet-session.js.map +0 -1
  386. package/dist/lib/native-tuning.js.map +0 -1
  387. package/dist/lib/p2p.d.ts +0 -32
  388. package/dist/lib/p2p.js +0 -281
  389. package/dist/lib/p2p.js.map +0 -1
  390. package/dist/lib/providers.d.ts +0 -1
  391. package/dist/lib/providers.js +0 -41
  392. package/dist/lib/providers.js.map +0 -1
  393. package/dist/lib/repair.d.ts +0 -10
  394. package/dist/lib/repair.js +0 -57
  395. package/dist/lib/repair.js.map +0 -1
  396. package/dist/lib/scanner.d.ts +0 -34
  397. package/dist/lib/scanner.js +0 -242
  398. package/dist/lib/scanner.js.map +0 -1
  399. package/dist/lib/search-tool.d.ts +0 -55
  400. package/dist/lib/search-tool.js +0 -319
  401. package/dist/lib/search-tool.js.map +0 -1
  402. package/dist/lib/serve.d.ts +0 -11
  403. package/dist/lib/serve.js +0 -144
  404. package/dist/lib/serve.js.map +0 -1
  405. package/dist/lib/store.d.ts +0 -252
  406. package/dist/lib/store.js +0 -1216
  407. package/dist/lib/store.js.map +0 -1
  408. package/dist/lib/types.d.ts +0 -194
  409. package/dist/lib/types.js +0 -13
  410. package/dist/lib/types.js.map +0 -1
  411. package/dist/lib/vocab.d.ts +0 -20
  412. package/dist/lib/vocab.js +0 -275
  413. package/dist/lib/vocab.js.map +0 -1
  414. /package/dist/{lib/native-tuning.d.ts → infrastructure/lancedb/NativeTuning.d.ts} +0 -0
package/dist/mcp.js CHANGED
@@ -1,79 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  process.title = "lmgrep-mcp";
3
- // Must come first — sets TOKIO/RAYON/UV thread caps before LanceDB native
3
+ // Must come first — sets TOKIO/RAYON/UV thread caps before the LanceDB native
4
4
  // binding initializes its runtime.
5
- import "./lib/native-tuning.js";
6
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
7
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
8
- import { z } from "zod";
9
- import { createLmgrepCore } from "./lib/search-tool.js";
10
- const core = await createLmgrepCore({ cwd: process.cwd() });
11
- const server = new McpServer({
12
- name: "lmgrep",
13
- version: "0.1.0",
14
- });
15
- const searchTool = server.tool("search", core.buildSearchDescription(), {
16
- query: z.string().describe(core.searchParams.query.description),
17
- limit: z
18
- .number()
19
- .optional()
20
- .default(core.searchParams.limit.default)
21
- .describe(core.searchParams.limit.description),
22
- filePrefix: z
23
- .string()
24
- .optional()
25
- .describe(core.searchParams.filePrefix.description),
26
- type: z
27
- .array(z.string())
28
- .optional()
29
- .describe(core.searchParams.type.description),
30
- language: z
31
- .array(z.string())
32
- .optional()
33
- .describe(core.searchParams.language.description),
34
- project: z
35
- .string()
36
- .optional()
37
- .describe(core.searchParams.project.description),
38
- }, async (args) => {
39
- const result = await core.executeSearch(args);
40
- return {
41
- content: [{ type: "text", text: result.text }],
42
- ...(result.isError ? { isError: true } : {}),
43
- };
44
- });
45
- server.tool("facet", core.facetDescription, {
46
- query: z.string().describe(core.facetParam.description),
47
- }, async (args) => {
48
- const result = await core.executeFacet(args);
49
- return {
50
- content: [{ type: "text", text: result.text }],
51
- ...(result.isError ? { isError: true } : {}),
52
- };
53
- });
54
- server.tool("list_other_indexed_projects", core.listProjectsDescription, {}, async () => {
55
- const result = await core.executeListProjects();
56
- return { content: [{ type: "text", text: result.text }] };
57
- });
58
- core.onHealthChange(() => {
59
- searchTool.update({ description: core.buildSearchDescription() });
60
- });
61
- core.start();
5
+ import "./infrastructure/lancedb/NativeTuning.js";
6
+ import { LmgrepCore } from "./presentation/mcp/LmgrepCore.js";
7
+ import { LmgrepMcpServer } from "./presentation/mcp/McpServer.js";
8
+ const core = await LmgrepCore.open({
9
+ cwd: process.cwd(),
10
+ database: process.env.LMGREP_DATABASE || undefined,
11
+ });
12
+ const shutdown = () => {
13
+ core.dispose().finally(() => process.exit(0));
14
+ };
62
15
  process.on("exit", () => {
63
16
  core.dispose().catch(() => { });
64
17
  });
65
- process.on("SIGINT", () => {
66
- core.dispose().finally(() => process.exit(0));
67
- });
68
- process.on("SIGTERM", () => {
69
- core.dispose().finally(() => process.exit(0));
70
- });
71
- async function main() {
72
- const transport = new StdioServerTransport();
73
- await server.connect(transport);
74
- }
75
- main().catch((err) => {
76
- console.error("lmgrep MCP server error:", err);
77
- process.exit(1);
78
- });
18
+ process.on("SIGINT", shutdown);
19
+ process.on("SIGTERM", shutdown);
20
+ await new LmgrepMcpServer(core).serve();
79
21
  //# sourceMappingURL=mcp.js.map
package/dist/mcp.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":";AACA,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC;AAE7B,0EAA0E;AAC1E,mCAAmC;AACnC,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAE5D,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC5B,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,OAAO;CAChB,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAC7B,QAAQ,EACR,IAAI,CAAC,sBAAsB,EAAE,EAC7B;IACC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC;IAC/D,KAAK,EAAE,CAAC;SACN,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;SACxC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC;IAC/C,UAAU,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,IAA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eAAe,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { CommandContext } from "./CommandContext.js";
2
+ /**
3
+ * Assembles and runs the command-line interface.
4
+ *
5
+ * Two things here are deliberate. A bare `lmgrep <words>` searches, because
6
+ * searching is what lmgrep is for and it should not cost a subcommand. And the
7
+ * help is grouped, because a flat list of a dozen commands says nothing about
8
+ * which two anyone actually needs — the first group is the whole product, and
9
+ * the rest is setup you do once.
10
+ */
11
+ export declare class Cli {
12
+ private readonly context;
13
+ /** Help grouping, by command name. Order here is order in `--help`. */
14
+ private static readonly GROUPS;
15
+ private readonly program;
16
+ constructor(context?: CommandContext);
17
+ run(argv?: string[]): Promise<void>;
18
+ /**
19
+ * Treat a leading word that is not a command as the start of a query.
20
+ *
21
+ * The ambiguity is real but small: `lmgrep status` is the command, not a
22
+ * search for the word "status". Anything of more than one word, and
23
+ * anything that is not a command name, searches — which covers every query
24
+ * a person would actually type.
25
+ */
26
+ private withImplicitSearch;
27
+ private commandNames;
28
+ private group;
29
+ private static looksLikeStdioLaunch;
30
+ private commands;
31
+ }
@@ -0,0 +1,120 @@
1
+ import { Command } from "commander";
2
+ import { CommandContext } from "./CommandContext.js";
3
+ import { AskCommand } from "./commands/AskCommand.js";
4
+ import { CompletionsCommand } from "./commands/CompletionsCommand.js";
5
+ import { ConfigCommands } from "./commands/ConfigCommands.js";
6
+ import { IndexCommand } from "./commands/IndexCommand.js";
7
+ import { ProjectsCommand } from "./commands/ProjectsCommand.js";
8
+ import { SearchCommand } from "./commands/SearchCommand.js";
9
+ import { ServerCommands } from "./commands/ServerCommands.js";
10
+ import { ShareCommands } from "./commands/ShareCommands.js";
11
+ import { StatusCommand } from "./commands/StatusCommand.js";
12
+ /**
13
+ * Assembles and runs the command-line interface.
14
+ *
15
+ * Two things here are deliberate. A bare `lmgrep <words>` searches, because
16
+ * searching is what lmgrep is for and it should not cost a subcommand. And the
17
+ * help is grouped, because a flat list of a dozen commands says nothing about
18
+ * which two anyone actually needs — the first group is the whole product, and
19
+ * the rest is setup you do once.
20
+ */
21
+ export class Cli {
22
+ context;
23
+ /** Help grouping, by command name. Order here is order in `--help`. */
24
+ static GROUPS = [
25
+ ["Searching:", ["search", "ask"]],
26
+ ["Your projects:", ["index", "status", "projects"]],
27
+ ["Setup:", ["init", "config", "mcp", "completions"]],
28
+ ["Other:", ["serve", "share", "import"]],
29
+ ];
30
+ program = new Command();
31
+ constructor(context = new CommandContext()) {
32
+ this.context = context;
33
+ this.program
34
+ .name("lmgrep")
35
+ .description("Semantic code search, powered by a local embedding model")
36
+ .version("0.1.0")
37
+ .showHelpAfterError()
38
+ .addHelpText("after", "\nA bare query searches: lmgrep how are webhooks authenticated" +
39
+ "\nFirst time here: lmgrep init → lmgrep index");
40
+ for (const command of this.commands())
41
+ command.register(this.program);
42
+ this.group();
43
+ }
44
+ async run(argv = process.argv) {
45
+ // With no arguments and both streams piped, this was launched as an
46
+ // MCP server over stdio rather than by a human at a terminal.
47
+ if (Cli.looksLikeStdioLaunch(argv)) {
48
+ await import("../../mcp.js");
49
+ return;
50
+ }
51
+ try {
52
+ await this.program.parseAsync(this.withImplicitSearch(argv));
53
+ }
54
+ catch (err) {
55
+ // Every failure reaching here is a user-facing condition — no
56
+ // index, an unreachable provider, incompatible embeddings — not a
57
+ // defect. Report the message and set an exit code; a stack trace
58
+ // would only bury it. Guarding once here means no command can
59
+ // forget to.
60
+ this.context.fail(err);
61
+ }
62
+ }
63
+ /**
64
+ * Treat a leading word that is not a command as the start of a query.
65
+ *
66
+ * The ambiguity is real but small: `lmgrep status` is the command, not a
67
+ * search for the word "status". Anything of more than one word, and
68
+ * anything that is not a command name, searches — which covers every query
69
+ * a person would actually type.
70
+ */
71
+ withImplicitSearch(argv) {
72
+ const rest = argv.slice(2);
73
+ const first = rest[0];
74
+ if (!first || first.startsWith("-"))
75
+ return argv;
76
+ if (this.commandNames().has(first))
77
+ return argv;
78
+ return [...argv.slice(0, 2), "search", ...rest];
79
+ }
80
+ commandNames() {
81
+ const names = new Set(["help"]);
82
+ for (const command of this.program.commands) {
83
+ names.add(command.name());
84
+ for (const alias of command.aliases())
85
+ names.add(alias);
86
+ }
87
+ return names;
88
+ }
89
+ group() {
90
+ const groupOf = new Map();
91
+ for (const [group, names] of Cli.GROUPS) {
92
+ for (const name of names)
93
+ groupOf.set(name, group);
94
+ }
95
+ for (const command of this.program.commands) {
96
+ const group = groupOf.get(command.name());
97
+ if (group)
98
+ command.helpGroup(group);
99
+ }
100
+ }
101
+ static looksLikeStdioLaunch(argv) {
102
+ return (argv.slice(2).length === 0 &&
103
+ !process.stdin.isTTY &&
104
+ !process.stdout.isTTY);
105
+ }
106
+ commands() {
107
+ return [
108
+ new SearchCommand(this.context),
109
+ new AskCommand(this.context),
110
+ new IndexCommand(this.context),
111
+ new StatusCommand(this.context),
112
+ new ProjectsCommand(this.context),
113
+ new ConfigCommands(this.context),
114
+ new ServerCommands(this.context),
115
+ new ShareCommands(this.context),
116
+ new CompletionsCommand(this.context),
117
+ ];
118
+ }
119
+ }
120
+ //# sourceMappingURL=Cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cli.js","sourceRoot":"","sources":["../../../src/presentation/cli/Cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8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AAK,EAAE,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;YACzC,KAAK,MAAM,IAAI,IAAI,KAAK;gBAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;QACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAC1C,IAAI,KAAK;gBAAE,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;IACF,CAAC;IAEO,MAAM,CAAC,oBAAoB,CAAC,IAAc;QACjD,OAAO,CACN,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC;YAC1B,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK;YACpB,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CACrB,CAAC;IACH,CAAC;IAEO,QAAQ;QACf,OAAO;YACN,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC;YAC/B,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;YAC5B,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;YAC9B,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC;YAC/B,IAAI,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;YACjC,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC;YAChC,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC;YAChC,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC;YAC/B,IAAI,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC;SACpC,CAAC;IACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Command } from "commander";
2
+ /** The one option every command shares, and its help text. */
3
+ export declare class CliOptions {
4
+ /**
5
+ * `--in` replaced three overlapping options — `--project`, `--across` and
6
+ * `--database` — which were three spellings of "somewhere other than here".
7
+ *
8
+ * A value with a separator is a project directory, because that is what
9
+ * people have to hand; a bare name is a standalone index kept in the state
10
+ * directory, for corpora that are not repositories.
11
+ */
12
+ static readonly TARGET: string;
13
+ static target(command: Command): Command;
14
+ /** Commander calls this once per occurrence of a repeatable option. */
15
+ private static collect;
16
+ /** The single target a write command operates on, if any. */
17
+ static single(targets: string[] | undefined): string | undefined;
18
+ }
@@ -0,0 +1,25 @@
1
+ /** The one option every command shares, and its help text. */
2
+ export class CliOptions {
3
+ /**
4
+ * `--in` replaced three overlapping options — `--project`, `--across` and
5
+ * `--database` — which were three spellings of "somewhere other than here".
6
+ *
7
+ * A value with a separator is a project directory, because that is what
8
+ * people have to hand; a bare name is a standalone index kept in the state
9
+ * directory, for corpora that are not repositories.
10
+ */
11
+ static TARGET = "Project directory, or the name of a standalone index. " +
12
+ "Repeat to search several at once; use `.` to include the current project.";
13
+ static target(command) {
14
+ return command.option("--in <project-or-name>", CliOptions.TARGET, CliOptions.collect, []);
15
+ }
16
+ /** Commander calls this once per occurrence of a repeatable option. */
17
+ static collect(value, previous) {
18
+ return [...previous, value];
19
+ }
20
+ /** The single target a write command operates on, if any. */
21
+ static single(targets) {
22
+ return targets && targets.length > 0 ? targets[0] : undefined;
23
+ }
24
+ }
25
+ //# sourceMappingURL=CliOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliOptions.js","sourceRoot":"","sources":["../../../src/presentation/cli/CliOptions.ts"],"names":[],"mappings":"AAEA,8DAA8D;AAC9D,MAAM,OAAO,UAAU;IACtB;;;;;;;OAOG;IACH,MAAM,CAAU,MAAM,GACrB,wDAAwD;QACxD,2EAA2E,CAAC;IAE7E,MAAM,CAAC,MAAM,CAAC,OAAgB;QAC7B,OAAO,OAAO,CAAC,MAAM,CACpB,wBAAwB,EACxB,UAAU,CAAC,MAAM,EACjB,UAAU,CAAC,OAAO,EAClB,EAAc,CACd,CAAC;IACH,CAAC;IAED,uEAAuE;IAC/D,MAAM,CAAC,OAAO,CAAC,KAAa,EAAE,QAAkB;QACvD,OAAO,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,6DAA6D;IAC7D,MAAM,CAAC,MAAM,CAAC,OAA6B;QAC1C,OAAO,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/D,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { Lmgrep } from "../../application/Lmgrep.js";
2
+ import { LmgrepFactory } from "../../application/LmgrepFactory.js";
3
+ import { Renderer } from "./Renderer.js";
4
+ /** Options every command accepts. */
5
+ export interface GlobalOptions {
6
+ /** Repeatable `--in` targets. Write commands use only the first. */
7
+ in?: string[];
8
+ }
9
+ /**
10
+ * Shared plumbing for CLI commands: opening an Lmgrep, closing it again, and
11
+ * turning a thrown error into an exit code.
12
+ *
13
+ * Commands run through {@link withLmgrep} rather than opening their own, so no
14
+ * command can forget to close the database — a leaked LanceDB connection keeps
15
+ * a native runtime and its buffers alive for the life of the process.
16
+ */
17
+ export declare class CommandContext {
18
+ readonly renderer: Renderer;
19
+ private readonly factory;
20
+ constructor(renderer?: Renderer, factory?: LmgrepFactory);
21
+ get cwd(): string;
22
+ open(options: GlobalOptions): Promise<Lmgrep>;
23
+ /**
24
+ * Split `--in` values into the three things they can mean.
25
+ *
26
+ * The first path-like value replaces the working directory — "act as if I
27
+ * were there" — which is what makes `status --in ../other` and
28
+ * `search --in ../other` mean the obvious thing without a second flag. Any
29
+ * further paths are additional projects to search. A bare name selects a
30
+ * standalone index instead.
31
+ */
32
+ static targets(options: GlobalOptions): {
33
+ cwd: string;
34
+ name?: string;
35
+ across: string[];
36
+ };
37
+ /** Open, run, and always close — even when `run` throws. */
38
+ withLmgrep<T>(options: GlobalOptions, run: (lmgrep: Lmgrep) => Promise<T>): Promise<T | undefined>;
39
+ /**
40
+ * Report a failure the way a CLI should: message on stderr, non-zero exit,
41
+ * no stack trace. Errors reaching here are user-facing conditions (no
42
+ * index, bad path, unreachable provider), not defects. Called once from
43
+ * {@link Cli.run} so no command can forget to.
44
+ */
45
+ fail(error: unknown): void;
46
+ static isPathLike(value: string): boolean;
47
+ static integer(value: string | undefined, fallback: number): number;
48
+ /** Parse a comma-separated option into trimmed values. */
49
+ static list(value?: string): string[] | undefined;
50
+ }
@@ -0,0 +1,88 @@
1
+ import { resolve } from "node:path";
2
+ import { LmgrepFactory } from "../../application/LmgrepFactory.js";
3
+ import { Renderer } from "./Renderer.js";
4
+ /**
5
+ * Shared plumbing for CLI commands: opening an Lmgrep, closing it again, and
6
+ * turning a thrown error into an exit code.
7
+ *
8
+ * Commands run through {@link withLmgrep} rather than opening their own, so no
9
+ * command can forget to close the database — a leaked LanceDB connection keeps
10
+ * a native runtime and its buffers alive for the life of the process.
11
+ */
12
+ export class CommandContext {
13
+ renderer;
14
+ factory;
15
+ constructor(renderer = new Renderer(), factory = new LmgrepFactory()) {
16
+ this.renderer = renderer;
17
+ this.factory = factory;
18
+ }
19
+ get cwd() {
20
+ return process.cwd();
21
+ }
22
+ async open(options) {
23
+ const targets = CommandContext.targets(options);
24
+ return this.factory.open({
25
+ cwd: targets.cwd,
26
+ database: targets.name,
27
+ onWarning: (message) => this.renderer.error(message),
28
+ });
29
+ }
30
+ /**
31
+ * Split `--in` values into the three things they can mean.
32
+ *
33
+ * The first path-like value replaces the working directory — "act as if I
34
+ * were there" — which is what makes `status --in ../other` and
35
+ * `search --in ../other` mean the obvious thing without a second flag. Any
36
+ * further paths are additional projects to search. A bare name selects a
37
+ * standalone index instead.
38
+ */
39
+ static targets(options) {
40
+ const values = options.in ?? [];
41
+ const paths = values.filter((v) => CommandContext.isPathLike(v));
42
+ const name = values.find((v) => !CommandContext.isPathLike(v));
43
+ return {
44
+ cwd: paths[0] ? resolve(process.cwd(), paths[0]) : process.cwd(),
45
+ name,
46
+ across: paths.slice(1),
47
+ };
48
+ }
49
+ /** Open, run, and always close — even when `run` throws. */
50
+ async withLmgrep(options, run) {
51
+ const lmgrep = await this.open(options);
52
+ try {
53
+ return await run(lmgrep);
54
+ }
55
+ finally {
56
+ await lmgrep.close();
57
+ }
58
+ }
59
+ /**
60
+ * Report a failure the way a CLI should: message on stderr, non-zero exit,
61
+ * no stack trace. Errors reaching here are user-facing conditions (no
62
+ * index, bad path, unreachable provider), not defects. Called once from
63
+ * {@link Cli.run} so no command can forget to.
64
+ */
65
+ fail(error) {
66
+ this.renderer.error(error instanceof Error ? error.message : String(error));
67
+ process.exitCode = 1;
68
+ }
69
+ static isPathLike(value) {
70
+ return (value.includes("/") ||
71
+ value.includes("\\") ||
72
+ value === "." ||
73
+ value === "..");
74
+ }
75
+ static integer(value, fallback) {
76
+ if (value === undefined)
77
+ return fallback;
78
+ const n = Number.parseInt(value, 10);
79
+ return Number.isNaN(n) ? fallback : n;
80
+ }
81
+ /** Parse a comma-separated option into trimmed values. */
82
+ static list(value) {
83
+ if (!value)
84
+ return undefined;
85
+ return value.split(",").map((s) => s.trim());
86
+ }
87
+ }
88
+ //# sourceMappingURL=CommandContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandContext.js","sourceRoot":"","sources":["../../../src/presentation/cli/CommandContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQzC;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IAEhB;IACQ;IAFlB,YACU,WAAqB,IAAI,QAAQ,EAAE,EAC3B,UAAyB,IAAI,aAAa,EAAE;QADpD,aAAQ,GAAR,QAAQ,CAA2B;QAC3B,YAAO,GAAP,OAAO,CAAqC;IAC3D,CAAC;IAEJ,IAAI,GAAG;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G,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;gBAAS,CAAC;YACV,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;IACF,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,KAAc;QAClB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5E,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,KAAa;QAC9B,OAAO,CACN,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;YACnB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;YACpB,KAAK,KAAK,GAAG;YACb,KAAK,KAAK,IAAI,CACd,CAAC;IACH,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,KAAyB,EAAE,QAAgB;QACzD,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAC;QACzC,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,0DAA0D;IAC1D,MAAM,CAAC,IAAI,CAAC,KAAc;QACzB,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;CACD"}
@@ -0,0 +1,31 @@
1
+ /** Everything `init` managed to work out about the local setup. */
2
+ export interface DetectedSettings {
3
+ model?: string;
4
+ baseURL?: string;
5
+ providerPackage?: string;
6
+ local?: boolean;
7
+ chatModel?: string;
8
+ prefixes?: {
9
+ query: string;
10
+ document: string;
11
+ family?: string;
12
+ };
13
+ /** Deliberate tuning from an existing config, carried through untouched. */
14
+ batchSize?: number;
15
+ maxTokens?: number;
16
+ dimensions?: number;
17
+ }
18
+ /**
19
+ * The starter `config.yml` written by `lmgrep init`.
20
+ *
21
+ * Every optional setting is present but commented out. That is deliberate: it
22
+ * doubles as the reference documentation a user actually reads, so an option
23
+ * they never knew existed is one line away rather than in a README.
24
+ *
25
+ * Only machine settings appear here. `ignore` and `extensions` describe a
26
+ * repository and belong in its `.lmgrep.yml`, where they can be committed and
27
+ * mean the same thing on every machine that checks it out.
28
+ */
29
+ export declare class ConfigTemplate {
30
+ static render(detected?: DetectedSettings): string;
31
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * The starter `config.yml` written by `lmgrep init`.
3
+ *
4
+ * Every optional setting is present but commented out. That is deliberate: it
5
+ * doubles as the reference documentation a user actually reads, so an option
6
+ * they never knew existed is one line away rather than in a README.
7
+ *
8
+ * Only machine settings appear here. `ignore` and `extensions` describe a
9
+ * repository and belong in its `.lmgrep.yml`, where they can be committed and
10
+ * mean the same thing on every machine that checks it out.
11
+ */
12
+ export class ConfigTemplate {
13
+ static render(detected) {
14
+ const modelLine = detected?.model
15
+ ? `model: ${detected.model}`
16
+ : "# model: ollama:nomic-embed-text # ← set your model here";
17
+ const baseURLLine = detected?.baseURL
18
+ ? `baseURL: ${detected.baseURL}`
19
+ : "# baseURL: http://localhost:11434/v1";
20
+ const providerLine = detected?.providerPackage
21
+ ? `provider: "${detected.providerPackage}"`
22
+ : '# provider: "@ai-sdk/openai-compatible"';
23
+ const localLine = detected?.local ? "local: true" : "# local: true";
24
+ // Asymmetric models need these and fail silently without them, so they
25
+ // are written out rather than left commented.
26
+ const prefixLines = detected?.prefixes
27
+ ? [
28
+ detected.prefixes.family
29
+ ? `# ${detected.prefixes.family} models are asymmetric — these prefixes are required.`
30
+ : "# Prefixes required by this model.",
31
+ `queryPrefix: ${JSON.stringify(detected.prefixes.query)}`,
32
+ `documentPrefix: ${JSON.stringify(detected.prefixes.document)}`,
33
+ ].join("\n")
34
+ : [
35
+ '# queryPrefix: "search_query: "',
36
+ '# documentPrefix: "search_document: "',
37
+ ].join("\n");
38
+ const chatLine = detected?.chatModel
39
+ ? `chatModel: ${detected.chatModel}`
40
+ : "# chatModel: lmstudio:qwen/qwen3.5-9b";
41
+ return `# lmgrep — this machine's inference setup.
42
+ #
43
+ # These settings say which local models to use and where they listen. They are
44
+ # not per project: each model keeps its own index, so changing \`model\` here
45
+ # selects a different database rather than invalidating an existing one.
46
+ #
47
+ # Per-repository settings (ignore patterns, file extensions) go in a
48
+ # .lmgrep.yml inside that repository.
49
+ #
50
+ # Quick start with Ollama:
51
+ # 1. Install: curl -fsSL https://ollama.com/install.sh | sh
52
+ # 2. Pull a model: ollama pull nomic-embed-text
53
+ # 3. Run: lmgrep init --force (to auto-detect)
54
+
55
+ # Embedding model in "provider:model" format
56
+ ${modelLine}
57
+
58
+ # Base URL for the embedding API
59
+ ${baseURLLine}
60
+
61
+ # AI SDK package providing the model
62
+ ${providerLine}
63
+
64
+ # Provider runs locally, so health checks may probe it freely
65
+ ${localLine}
66
+
67
+ # Batch size for embedding API calls
68
+ batchSize: ${detected?.batchSize ?? 100}
69
+
70
+ ${prefixLines}
71
+
72
+ # Generative model for \`lmgrep ask\`. Optional — without it, \`ask\` is hidden.
73
+ ${chatLine}
74
+
75
+ # Optional: embedding dimensions (if model supports it)
76
+ ${detected?.dimensions ? `dimensions: ${detected.dimensions}` : "# dimensions: 384"}
77
+
78
+ # Optional: max tokens per chunk (estimated at 4 chars/token)
79
+ ${detected?.maxTokens ? `maxTokens: ${detected.maxTokens}` : "# maxTokens: 8192"}
80
+ `;
81
+ }
82
+ }
83
+ //# sourceMappingURL=ConfigTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigTemplate.js","sourceRoot":"","sources":["../../../src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