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,96 @@
1
+ import { execSync } from "node:child_process";
2
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { join } from "node:path";
5
+ /** `lmgrep completions` — shell completion scripts. */
6
+ export class CompletionsCommand {
7
+ context;
8
+ /** Preferred first: a user-local path needs no privileges. */
9
+ static ZSH_CANDIDATES = [
10
+ join(homedir(), ".local", "share", "zsh", "site-functions"),
11
+ "/usr/local/share/zsh/site-functions",
12
+ "/usr/share/zsh/site-functions",
13
+ ];
14
+ constructor(context) {
15
+ this.context = context;
16
+ }
17
+ register(program) {
18
+ const completions = program
19
+ .command("completions")
20
+ .description("Output shell completions");
21
+ completions
22
+ .command("zsh")
23
+ .description("Output zsh completions")
24
+ .option("--install", "Install to site-functions and reload completions")
25
+ .action((options) => this.runZsh(options));
26
+ }
27
+ runZsh(options) {
28
+ const { renderer } = this.context;
29
+ // Resolved relative to the built script, since the package ships the
30
+ // completions directory alongside dist/.
31
+ const script = readFileSync(join(import.meta.dirname, "..", "..", "..", "..", "completions", "_lmgrep"), "utf-8");
32
+ if (!options.install) {
33
+ renderer.line(script);
34
+ return;
35
+ }
36
+ const target = this.findSiteFunctions();
37
+ if (!target) {
38
+ renderer.error("Could not find a writable zsh site-functions directory.\n" +
39
+ "Output manually with: lmgrep completions zsh > /path/to/_lmgrep");
40
+ process.exitCode = 1;
41
+ return;
42
+ }
43
+ mkdirSync(target, { recursive: true });
44
+ writeFileSync(join(target, "_lmgrep"), script);
45
+ renderer.line(`Installed completions to ${join(target, "_lmgrep")}`);
46
+ renderer.line("Restart your shell or run: exec zsh");
47
+ }
48
+ /**
49
+ * The first candidate directory that exists and is writable, or that we can
50
+ * create. `$fpath` is consulted too, since a user's zsh setup may put
51
+ * site-functions somewhere unusual.
52
+ */
53
+ findSiteFunctions() {
54
+ const candidates = [...CompletionsCommand.ZSH_CANDIDATES];
55
+ for (const entry of this.fpathEntries()) {
56
+ if (entry.includes("site-functions") && !candidates.includes(entry)) {
57
+ candidates.push(entry);
58
+ }
59
+ }
60
+ for (const candidate of candidates) {
61
+ try {
62
+ if (existsSync(candidate)) {
63
+ // Probe rather than trust: an existing directory may be
64
+ // root-owned.
65
+ const probe = join(candidate, ".lmgrep-test");
66
+ writeFileSync(probe, "");
67
+ rmSync(probe);
68
+ return candidate;
69
+ }
70
+ if (existsSync(join(candidate, ".."))) {
71
+ mkdirSync(candidate, { recursive: true });
72
+ return candidate;
73
+ }
74
+ }
75
+ catch {
76
+ // Not writable — try the next candidate.
77
+ }
78
+ }
79
+ return undefined;
80
+ }
81
+ fpathEntries() {
82
+ try {
83
+ return execSync("zsh -c 'echo $fpath'", {
84
+ stdio: ["ignore", "pipe", "ignore"],
85
+ timeout: 3000,
86
+ })
87
+ .toString()
88
+ .trim()
89
+ .split(" ");
90
+ }
91
+ catch {
92
+ return [];
93
+ }
94
+ }
95
+ }
96
+ //# sourceMappingURL=CompletionsCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompletionsCommand.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/CompletionsCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EACN,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,EACN,aAAa,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,uDAAuD;AACvD,MAAM,OAAO,kBAAkB;IAQD;IAP7B,8DAA8D;IACtD,MAAM,CAAU,cAAc,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IAClB,CAAC;IAEO,YAAY;QACnB,IAAI,CAAC;YACJ,OAAO,QAAQ,CAAC,sBAAsB,EAAE;gBACvC,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;gBACnC,OAAO,EAAE,IAAI;aACb,CAAC;iBACA,QAAQ,EAAE;iBACV,IAAI,EAAE;iBACN,KAAK,CAAC,GAAG,CAAC,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,EAAE,CAAC;QACX,CAAC;IACF,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { Command } from "commander";
2
+ import type { CommandContext } from "../CommandContext.js";
3
+ /**
4
+ * `init` and `config` — getting a working configuration.
5
+ *
6
+ * Both write exactly one file: the machine config. Which model to embed with
7
+ * describes this computer, not any repository, so there is one place it can
8
+ * live and one file to edit when it is wrong.
9
+ *
10
+ * `init` no longer has to reason about which model an existing index was built
11
+ * with. Indexes are stored per model, so choosing a different one selects a
12
+ * different database rather than corrupting the meaning of an existing one —
13
+ * an entire class of "you must pick a compatible model" logic that stopped
14
+ * being necessary the moment the storage layout changed.
15
+ */
16
+ export declare class ConfigCommands {
17
+ private readonly context;
18
+ constructor(context: CommandContext);
19
+ register(program: Command): void;
20
+ private registerInit;
21
+ private runInit;
22
+ /**
23
+ * Keep the model the config already names, when the runtime still offers it.
24
+ *
25
+ * Detection reads whatever the server lists first or happens to have
26
+ * loaded, and both move — LM Studio reorders by recency and unloads when
27
+ * idle. A model written in the config is a decision; re-deriving one from
28
+ * volatile state would silently swap it.
29
+ */
30
+ private keepConfigured;
31
+ /**
32
+ * Prefixes to write: the ones already configured win, since they may be
33
+ * hand-tuned for a model this table knows nothing about, and an empty
34
+ * document prefix is a deliberate setting rather than an absent one.
35
+ */
36
+ private prefixesFor;
37
+ private selectEmbeddingModel;
38
+ /**
39
+ * Pick a model for `ask`, but only one the runtime typed as a chat model.
40
+ * Guessing here surfaces as a confusing failure much later, at answer time.
41
+ */
42
+ private selectChatModel;
43
+ /**
44
+ * Name the models not chosen.
45
+ *
46
+ * The pick is a guess whenever nothing is loaded, and switching means
47
+ * editing one config line — but only if the user knows what else was
48
+ * there. Switching is now cheap and reversible, since each model keeps its
49
+ * own index, but it still costs a re-embed the first time.
50
+ */
51
+ private reportAlternatives;
52
+ private reportNoRuntime;
53
+ private write;
54
+ private registerConfig;
55
+ }
@@ -0,0 +1,204 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
3
+ import { dirname } from "node:path";
4
+ import { ModelIdentity } from "../../../domain/project/ModelIdentity.js";
5
+ import { EmbeddingPrefixes } from "../../../infrastructure/ai/EmbeddingPrefixes.js";
6
+ import { LocalRuntimeDetector } from "../../../infrastructure/ai/LocalRuntimeDetector.js";
7
+ import { ConfigLoader } from "../../../infrastructure/fs/ConfigLoader.js";
8
+ import { ConfigTemplate } from "../ConfigTemplate.js";
9
+ /**
10
+ * `init` and `config` — getting a working configuration.
11
+ *
12
+ * Both write exactly one file: the machine config. Which model to embed with
13
+ * describes this computer, not any repository, so there is one place it can
14
+ * live and one file to edit when it is wrong.
15
+ *
16
+ * `init` no longer has to reason about which model an existing index was built
17
+ * with. Indexes are stored per model, so choosing a different one selects a
18
+ * different database rather than corrupting the meaning of an existing one —
19
+ * an entire class of "you must pick a compatible model" logic that stopped
20
+ * being necessary the moment the storage layout changed.
21
+ */
22
+ export class ConfigCommands {
23
+ context;
24
+ constructor(context) {
25
+ this.context = context;
26
+ }
27
+ register(program) {
28
+ this.registerInit(program);
29
+ this.registerConfig(program);
30
+ }
31
+ registerInit(program) {
32
+ program
33
+ .command("init")
34
+ .description("Detect your local models and write the machine config")
35
+ .option("--force", "Overwrite the existing config")
36
+ .action((options) => this.runInit(options));
37
+ }
38
+ async runInit(options) {
39
+ const { renderer } = this.context;
40
+ const loader = new ConfigLoader();
41
+ const configPath = loader.globalConfigPath();
42
+ if (existsSync(configPath) && !options.force) {
43
+ renderer.error(`Config already exists at ${configPath}. Use --force to re-detect, or \`lmgrep config\` to edit.`);
44
+ process.exitCode = 1;
45
+ return;
46
+ }
47
+ // The config already at this path is an explicit prior choice.
48
+ const previous = loader.readFile(configPath);
49
+ const runtime = await new LocalRuntimeDetector().detectBest();
50
+ if (!runtime) {
51
+ this.reportNoRuntime();
52
+ this.write(configPath, ConfigTemplate.render());
53
+ renderer.line(`\nWrote ${configPath} (set a model before indexing)`);
54
+ return;
55
+ }
56
+ renderer.line(`Found ${runtime.label}.`);
57
+ const model = this.keepConfigured(runtime, previous?.model, "embedding") ??
58
+ this.selectEmbeddingModel(runtime);
59
+ const chatModel = this.keepConfigured(runtime, previous?.chatModel, "chat") ??
60
+ this.selectChatModel(runtime);
61
+ this.write(configPath, ConfigTemplate.render({
62
+ model: model ? `${runtime.providerId}:${model}` : undefined,
63
+ baseURL: model ? runtime.baseURL : undefined,
64
+ providerPackage: model ? runtime.providerPackage : undefined,
65
+ local: model ? true : undefined,
66
+ chatModel: chatModel ? `${runtime.providerId}:${chatModel}` : undefined,
67
+ prefixes: this.prefixesFor(model, previous),
68
+ // Carried through rather than regenerated: this is tuning the
69
+ // user chose, and init has no better answer than they did.
70
+ batchSize: previous?.batchSize,
71
+ maxTokens: previous?.maxTokens,
72
+ dimensions: previous?.dimensions,
73
+ }));
74
+ renderer.line(`Wrote ${configPath}`);
75
+ }
76
+ /**
77
+ * Keep the model the config already names, when the runtime still offers it.
78
+ *
79
+ * Detection reads whatever the server lists first or happens to have
80
+ * loaded, and both move — LM Studio reorders by recency and unloads when
81
+ * idle. A model written in the config is a decision; re-deriving one from
82
+ * volatile state would silently swap it.
83
+ */
84
+ keepConfigured(runtime, configured, kind) {
85
+ if (!configured)
86
+ return undefined;
87
+ const reference = ModelIdentity.of(configured);
88
+ if (reference.provider !== runtime.providerId)
89
+ return undefined;
90
+ if (!runtime.models.some((m) => m.id === reference.family)) {
91
+ this.context.renderer.line(`Configured ${kind} model "${reference.family}" is no longer available in ${runtime.label}.`);
92
+ return undefined;
93
+ }
94
+ this.context.renderer.line(`Keeping configured ${kind} model: ${reference.family}`);
95
+ return reference.family;
96
+ }
97
+ /**
98
+ * Prefixes to write: the ones already configured win, since they may be
99
+ * hand-tuned for a model this table knows nothing about, and an empty
100
+ * document prefix is a deliberate setting rather than an absent one.
101
+ */
102
+ prefixesFor(model, previous) {
103
+ if (previous?.queryPrefix !== undefined) {
104
+ return {
105
+ query: previous.queryPrefix,
106
+ document: previous.documentPrefix ?? "",
107
+ };
108
+ }
109
+ return model ? EmbeddingPrefixes.forModel(model) : undefined;
110
+ }
111
+ selectEmbeddingModel(runtime) {
112
+ const { renderer } = this.context;
113
+ const embedders = LocalRuntimeDetector.embeddingModels(runtime);
114
+ // Runtimes that do not type their models still list them; treat the
115
+ // untyped ones as last-resort candidates.
116
+ const candidates = [
117
+ ...embedders,
118
+ ...LocalRuntimeDetector.untypedModels(runtime),
119
+ ];
120
+ const picked = embedders[0] ?? candidates[0];
121
+ if (!picked) {
122
+ renderer.line(`\nNo models available in ${runtime.label}.`);
123
+ renderer.line("Install an embedding model (e.g. nomic-embed-text), then run `lmgrep init` again.");
124
+ return undefined;
125
+ }
126
+ renderer.line(`Using embedding model: ${picked.id}${picked.loaded ? " (loaded)" : ""}`);
127
+ if (picked.kind !== "embedding") {
128
+ renderer.line(" (this model's type could not be confirmed — check it is an embedder)");
129
+ }
130
+ this.reportAlternatives(candidates, picked.id);
131
+ const prefixes = EmbeddingPrefixes.forModel(picked.id);
132
+ if (prefixes) {
133
+ renderer.line(` ${prefixes.family} is asymmetric — writing its required prefixes`);
134
+ }
135
+ return picked.id;
136
+ }
137
+ /**
138
+ * Pick a model for `ask`, but only one the runtime typed as a chat model.
139
+ * Guessing here surfaces as a confusing failure much later, at answer time.
140
+ */
141
+ selectChatModel(runtime) {
142
+ const [picked] = LocalRuntimeDetector.chatModels(runtime);
143
+ if (!picked)
144
+ return undefined;
145
+ this.context.renderer.line(`Using chat model for \`ask\`: ${picked.id}${picked.loaded ? " (loaded)" : ""}`);
146
+ return picked.id;
147
+ }
148
+ /**
149
+ * Name the models not chosen.
150
+ *
151
+ * The pick is a guess whenever nothing is loaded, and switching means
152
+ * editing one config line — but only if the user knows what else was
153
+ * there. Switching is now cheap and reversible, since each model keeps its
154
+ * own index, but it still costs a re-embed the first time.
155
+ */
156
+ reportAlternatives(candidates, chosen) {
157
+ const others = candidates.filter((m) => m.id !== chosen);
158
+ if (others.length === 0)
159
+ return;
160
+ this.context.renderer.line(` Also available: ${others.map((m) => m.id).join(", ")}`);
161
+ this.context.renderer.line(" Change `model` in the config to switch.");
162
+ }
163
+ reportNoRuntime() {
164
+ const { renderer } = this.context;
165
+ renderer.line("No local embedding server detected.\n");
166
+ renderer.line("Start one of:");
167
+ renderer.line(" Ollama curl -fsSL https://ollama.com/install.sh | sh");
168
+ renderer.line(" LM Studio https://lmstudio.ai — enable the local server");
169
+ renderer.line("");
170
+ renderer.line("Then run `lmgrep init` again to auto-configure, or edit the config by hand.");
171
+ }
172
+ write(configPath, contents) {
173
+ mkdirSync(dirname(configPath), { recursive: true });
174
+ writeFileSync(configPath, contents);
175
+ }
176
+ registerConfig(program) {
177
+ program
178
+ .command("config")
179
+ .description("Open the machine config in your editor")
180
+ .action(() => {
181
+ const { renderer } = this.context;
182
+ const configPath = new ConfigLoader().globalConfigPath();
183
+ if (!existsSync(configPath)) {
184
+ renderer.error(`No config found at ${configPath}. Run \`lmgrep init\` first.`);
185
+ process.exitCode = 1;
186
+ return;
187
+ }
188
+ const editorCommand = process.env.VISUAL ?? process.env.EDITOR ?? "vi";
189
+ renderer.line(`Opening ${configPath}`);
190
+ // $EDITOR may carry flags ("code -w"), so split those off — but
191
+ // pass the path as its own argv entry, or a directory with
192
+ // spaces (macOS "Application Support") gets re-split.
193
+ const [editor, ...args] = editorCommand.trim().split(/\s+/);
194
+ const result = spawnSync(editor, [...args, configPath], {
195
+ stdio: "inherit",
196
+ });
197
+ if (result.error || (result.status != null && result.status !== 0)) {
198
+ renderer.error(`Could not open editor "${editorCommand}". Set $EDITOR or $VISUAL.`);
199
+ process.exitCode = 1;
200
+ }
201
+ });
202
+ }
203
+ }
204
+ //# sourceMappingURL=ConfigCommands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigCommands.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/ConfigCommands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAE1F,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IACG;IAA7B,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,QAAQ,CAAC,OAAgB;QACxB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC3B,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAEO,YAAY,CAAC,OAAgB;QACpC,OAAO;aACL,OAAO,CAAC,MAAM,CAAC;aACf,WAAW,CAAC,uDAAuD,CAAC;aACpE,MAAM,CAAC,SAAS,EAAE,+BAA+B,CAAC;aAClD,MAAM,CAAC,CAAC,OAA4B,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,OAA4B;QACjD,MAAM,EAAE,QAA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AG,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC;YACvE,QAAQ,CAAC,IAAI,CAAC,WAAW,UAAU,EAAE,CAAC,CAAC;YAEvC,gEAAgE;YAChE,2DAA2D;YAC3D,sDAAsD;YACtD,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC5D,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE;gBACvD,KAAK,EAAE,SAAS;aAChB,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;gBACpE,QAAQ,CAAC,KAAK,CACb,0BAA0B,aAAa,4BAA4B,CACnE,CAAC;gBACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACtB,CAAC;QACF,CAAC,CAAC,CAAC;IACL,CAAC;CACD"}
@@ -0,0 +1,18 @@
1
+ import type { Command } from "commander";
2
+ import type { CommandContext } from "../CommandContext.js";
3
+ /**
4
+ * `lmgrep index` — adopt a project, and keep it current.
5
+ *
6
+ * This is the one moment a user consents to lmgrep reading a whole repository
7
+ * and spending time embedding it, which is why it stays an explicit command
8
+ * rather than something a search triggers. Everything that used to be a
9
+ * separate chore afterwards — reconciling the manifest, dropping duplicate
10
+ * rows, compacting fragments, training the vector index — happens here, at the
11
+ * one moment someone is already waiting and watching.
12
+ */
13
+ export declare class IndexCommand {
14
+ private readonly context;
15
+ constructor(context: CommandContext);
16
+ register(program: Command): void;
17
+ private run;
18
+ }
@@ -0,0 +1,54 @@
1
+ import { CliOptions } from "../CliOptions.js";
2
+ /**
3
+ * `lmgrep index` — adopt a project, and keep it current.
4
+ *
5
+ * This is the one moment a user consents to lmgrep reading a whole repository
6
+ * and spending time embedding it, which is why it stays an explicit command
7
+ * rather than something a search triggers. Everything that used to be a
8
+ * separate chore afterwards — reconciling the manifest, dropping duplicate
9
+ * rows, compacting fragments, training the vector index — happens here, at the
10
+ * one moment someone is already waiting and watching.
11
+ */
12
+ export class IndexCommand {
13
+ context;
14
+ constructor(context) {
15
+ this.context = context;
16
+ }
17
+ register(program) {
18
+ CliOptions.target(program
19
+ .command("index")
20
+ .description("Index this project for semantic search")
21
+ .option("-r, --reset", "Discard the index and rebuild from scratch")
22
+ .option("-v, --verbose", "Show file-by-file progress")
23
+ .option("-s, --since <duration>", "Only consider files modified within duration (e.g. 10m, 2h, 1d)")
24
+ .option("-d, --dry", "Report what would be indexed, and stop")).action((options) => this.run(options));
25
+ }
26
+ async run(options) {
27
+ await this.context.withLmgrep(options, async (lmgrep) => {
28
+ // Said before the work starts, not after: embedding a repository
29
+ // with a newly configured model can take a long time, and someone
30
+ // who only meant to try a model out should get the chance to put
31
+ // the old one back instead of watching it run.
32
+ this.context.renderer.newModelNotice(lmgrep.alternatives.others());
33
+ const result = await lmgrep.build({
34
+ reset: options.reset,
35
+ verbose: options.verbose,
36
+ since: options.since,
37
+ dry: options.dry,
38
+ // A foreground command the user is watching, so it is the right
39
+ // place to pay the one-time ANN training cost.
40
+ createIndex: true,
41
+ });
42
+ if (options.dry)
43
+ return;
44
+ // Only after a run that changed something: deduplication reads
45
+ // every row, and paying that on `lmgrep index` over an unchanged
46
+ // repository would make the no-op case the slow one.
47
+ if (result.succeeded > 0 || result.removed > 0) {
48
+ this.context.renderer.maintenance(await lmgrep.tidy());
49
+ }
50
+ this.context.renderer.line(`\nIndex: ${lmgrep.location.path}`);
51
+ });
52
+ }
53
+ }
54
+ //# sourceMappingURL=IndexCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndexCommand.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/IndexCommand.ts"],"names":[],"mappings":"AAC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DAAqD;YACrD,IAAI,MAAM,CAAC,SAAS,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;gBAChD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACxD,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
@@ -0,0 +1,48 @@
1
+ import type { Command } from "commander";
2
+ import type { CommandContext } from "../CommandContext.js";
3
+ /**
4
+ * `lmgrep projects` — every index on this machine, and what to do about it.
5
+ *
6
+ * This is the answer to the state lmgrep used to accumulate silently. An index
7
+ * now lives inside the repository it describes, so deleting the clone deletes
8
+ * the index; but installs that predate that still hold databases in the state
9
+ * directory, pointing at working trees that may be long gone. `adopt` moves
10
+ * one into its repository without re-embedding, `rm` deletes one, and `gc`
11
+ * removes the ones whose project no longer exists.
12
+ */
13
+ export declare class ProjectsCommand {
14
+ private readonly context;
15
+ private readonly state;
16
+ private readonly metadata;
17
+ private readonly registry;
18
+ constructor(context: CommandContext);
19
+ register(program: Command): void;
20
+ private list;
21
+ /**
22
+ * Move a legacy database into its repository.
23
+ *
24
+ * Worth doing rather than re-indexing because the expensive part of an
25
+ * index is the embedding, not the storage — a large corpus is minutes of
26
+ * model time to rebuild and a rename to move. The destination is derived
27
+ * from the model the database *was built with*, not the one currently
28
+ * configured, so it lands where searches with that model will look.
29
+ */
30
+ private adopt;
31
+ private remove;
32
+ /**
33
+ * Delete indexes whose project is gone.
34
+ *
35
+ * "Records no project" is excluded unless asked for. It is a recursive
36
+ * delete, and an index with no metadata is not evidence that its project
37
+ * vanished — only that nothing was written down about it. Treating the two
38
+ * as one would have made `gc` destroy far more than it claimed to.
39
+ */
40
+ private collect;
41
+ /** Whether a legacy entry describes the project at `cwd`. */
42
+ private sameProject;
43
+ /** Rename when possible; copy across filesystems, which repos often are. */
44
+ private move;
45
+ private inventory;
46
+ private locator;
47
+ private confirm;
48
+ }