lmgrep 0.1.18 → 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 (408) 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 +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 +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 -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/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/{lib/native-tuning.js → infrastructure/lancedb/NativeTuning.js} +1 -1
  265. package/dist/infrastructure/lancedb/NativeTuning.js.map +1 -0
  266. package/dist/infrastructure/lancedb/RowReplication.d.ts +27 -0
  267. package/dist/infrastructure/lancedb/RowReplication.js +82 -0
  268. package/dist/infrastructure/lancedb/RowReplication.js.map +1 -0
  269. package/dist/infrastructure/lancedb/VectorIndexPolicy.d.ts +60 -0
  270. package/dist/infrastructure/lancedb/VectorIndexPolicy.js +72 -0
  271. package/dist/infrastructure/lancedb/VectorIndexPolicy.js.map +1 -0
  272. package/dist/infrastructure/p2p/IndexShare.d.ts +45 -0
  273. package/dist/infrastructure/p2p/IndexShare.js +160 -0
  274. package/dist/infrastructure/p2p/IndexShare.js.map +1 -0
  275. package/dist/infrastructure/p2p/PeerSwarm.d.ts +16 -0
  276. package/dist/infrastructure/p2p/PeerSwarm.js +41 -0
  277. package/dist/infrastructure/p2p/PeerSwarm.js.map +1 -0
  278. package/dist/infrastructure/p2p/SecureChannel.d.ts +60 -0
  279. package/dist/infrastructure/p2p/SecureChannel.js +71 -0
  280. package/dist/infrastructure/p2p/SecureChannel.js.map +1 -0
  281. package/dist/infrastructure/p2p/ShareCode.d.ts +25 -0
  282. package/dist/infrastructure/p2p/ShareCode.js +304 -0
  283. package/dist/infrastructure/p2p/ShareCode.js.map +1 -0
  284. package/dist/infrastructure/process/ProcessRegistry.d.ts +50 -0
  285. package/dist/infrastructure/process/ProcessRegistry.js +109 -0
  286. package/dist/infrastructure/process/ProcessRegistry.js.map +1 -0
  287. package/dist/infrastructure/treesitter/ChunkContextBuilder.d.ts +45 -0
  288. package/dist/infrastructure/treesitter/ChunkContextBuilder.js +159 -0
  289. package/dist/infrastructure/treesitter/ChunkContextBuilder.js.map +1 -0
  290. package/dist/infrastructure/treesitter/LanguageCatalog.d.ts +30 -0
  291. package/dist/{lib/chunker/languages.js → infrastructure/treesitter/LanguageCatalog.js} +34 -29
  292. package/dist/infrastructure/treesitter/LanguageCatalog.js.map +1 -0
  293. package/dist/infrastructure/treesitter/SlidingWindowChunker.d.ts +15 -0
  294. package/dist/infrastructure/treesitter/SlidingWindowChunker.js +42 -0
  295. package/dist/infrastructure/treesitter/SlidingWindowChunker.js.map +1 -0
  296. package/dist/infrastructure/treesitter/TreeSitterChunker.d.ts +42 -0
  297. package/dist/infrastructure/treesitter/TreeSitterChunker.js +163 -0
  298. package/dist/infrastructure/treesitter/TreeSitterChunker.js.map +1 -0
  299. package/dist/mcp.d.ts +1 -1
  300. package/dist/mcp.js +14 -72
  301. package/dist/mcp.js.map +1 -1
  302. package/dist/presentation/cli/Cli.d.ts +31 -0
  303. package/dist/presentation/cli/Cli.js +120 -0
  304. package/dist/presentation/cli/Cli.js.map +1 -0
  305. package/dist/presentation/cli/CliOptions.d.ts +18 -0
  306. package/dist/presentation/cli/CliOptions.js +25 -0
  307. package/dist/presentation/cli/CliOptions.js.map +1 -0
  308. package/dist/presentation/cli/CommandContext.d.ts +50 -0
  309. package/dist/presentation/cli/CommandContext.js +88 -0
  310. package/dist/presentation/cli/CommandContext.js.map +1 -0
  311. package/dist/presentation/cli/ConfigTemplate.d.ts +31 -0
  312. package/dist/presentation/cli/ConfigTemplate.js +83 -0
  313. package/dist/presentation/cli/ConfigTemplate.js.map +1 -0
  314. package/dist/presentation/cli/Renderer.d.ts +90 -0
  315. package/dist/presentation/cli/Renderer.js +290 -0
  316. package/dist/presentation/cli/Renderer.js.map +1 -0
  317. package/dist/presentation/cli/commands/AskCommand.d.ts +14 -0
  318. package/dist/presentation/cli/commands/AskCommand.js +48 -0
  319. package/dist/presentation/cli/commands/AskCommand.js.map +1 -0
  320. package/dist/presentation/cli/commands/CompletionsCommand.d.ts +18 -0
  321. package/dist/presentation/cli/commands/CompletionsCommand.js +96 -0
  322. package/dist/presentation/cli/commands/CompletionsCommand.js.map +1 -0
  323. package/dist/presentation/cli/commands/ConfigCommands.d.ts +55 -0
  324. package/dist/presentation/cli/commands/ConfigCommands.js +204 -0
  325. package/dist/presentation/cli/commands/ConfigCommands.js.map +1 -0
  326. package/dist/presentation/cli/commands/IndexCommand.d.ts +18 -0
  327. package/dist/presentation/cli/commands/IndexCommand.js +54 -0
  328. package/dist/presentation/cli/commands/IndexCommand.js.map +1 -0
  329. package/dist/presentation/cli/commands/ProjectsCommand.d.ts +48 -0
  330. package/dist/presentation/cli/commands/ProjectsCommand.js +240 -0
  331. package/dist/presentation/cli/commands/ProjectsCommand.js.map +1 -0
  332. package/dist/presentation/cli/commands/SearchCommand.d.ts +19 -0
  333. package/dist/presentation/cli/commands/SearchCommand.js +55 -0
  334. package/dist/presentation/cli/commands/SearchCommand.js.map +1 -0
  335. package/dist/presentation/cli/commands/ServerCommands.d.ts +13 -0
  336. package/dist/presentation/cli/commands/ServerCommands.js +40 -0
  337. package/dist/presentation/cli/commands/ServerCommands.js.map +1 -0
  338. package/dist/presentation/cli/commands/ShareCommands.d.ts +22 -0
  339. package/dist/presentation/cli/commands/ShareCommands.js +134 -0
  340. package/dist/presentation/cli/commands/ShareCommands.js.map +1 -0
  341. package/dist/presentation/cli/commands/StatusCommand.d.ts +15 -0
  342. package/dist/presentation/cli/commands/StatusCommand.js +53 -0
  343. package/dist/presentation/cli/commands/StatusCommand.js.map +1 -0
  344. package/dist/presentation/mcp/HitFormatter.d.ts +17 -0
  345. package/dist/presentation/mcp/HitFormatter.js +42 -0
  346. package/dist/presentation/mcp/HitFormatter.js.map +1 -0
  347. package/dist/presentation/mcp/IndexWatchController.d.ts +17 -0
  348. package/dist/presentation/mcp/IndexWatchController.js +31 -0
  349. package/dist/presentation/mcp/IndexWatchController.js.map +1 -0
  350. package/dist/presentation/mcp/LmgrepCore.d.ts +66 -0
  351. package/dist/presentation/mcp/LmgrepCore.js +178 -0
  352. package/dist/presentation/mcp/LmgrepCore.js.map +1 -0
  353. package/dist/presentation/mcp/McpServer.d.ts +18 -0
  354. package/dist/presentation/mcp/McpServer.js +63 -0
  355. package/dist/presentation/mcp/McpServer.js.map +1 -0
  356. package/dist/presentation/mcp/ToolDescriptions.d.ts +40 -0
  357. package/dist/presentation/mcp/ToolDescriptions.js +85 -0
  358. package/dist/presentation/mcp/ToolDescriptions.js.map +1 -0
  359. package/package.json +84 -89
  360. package/dist/lib/build.d.ts +0 -21
  361. package/dist/lib/build.js +0 -374
  362. package/dist/lib/build.js.map +0 -1
  363. package/dist/lib/chunker/context.d.ts +0 -21
  364. package/dist/lib/chunker/context.js +0 -131
  365. package/dist/lib/chunker/context.js.map +0 -1
  366. package/dist/lib/chunker/index.d.ts +0 -7
  367. package/dist/lib/chunker/index.js +0 -209
  368. package/dist/lib/chunker/index.js.map +0 -1
  369. package/dist/lib/chunker/languages.d.ts +0 -15
  370. package/dist/lib/chunker/languages.js.map +0 -1
  371. package/dist/lib/config.d.ts +0 -12
  372. package/dist/lib/config.js +0 -83
  373. package/dist/lib/config.js.map +0 -1
  374. package/dist/lib/embedder.d.ts +0 -65
  375. package/dist/lib/embedder.js +0 -236
  376. package/dist/lib/embedder.js.map +0 -1
  377. package/dist/lib/facet-session.d.ts +0 -44
  378. package/dist/lib/facet-session.js +0 -125
  379. package/dist/lib/facet-session.js.map +0 -1
  380. package/dist/lib/native-tuning.js.map +0 -1
  381. package/dist/lib/p2p.d.ts +0 -32
  382. package/dist/lib/p2p.js +0 -281
  383. package/dist/lib/p2p.js.map +0 -1
  384. package/dist/lib/providers.d.ts +0 -1
  385. package/dist/lib/providers.js +0 -41
  386. package/dist/lib/providers.js.map +0 -1
  387. package/dist/lib/repair.d.ts +0 -10
  388. package/dist/lib/repair.js +0 -57
  389. package/dist/lib/repair.js.map +0 -1
  390. package/dist/lib/scanner.d.ts +0 -34
  391. package/dist/lib/scanner.js +0 -242
  392. package/dist/lib/scanner.js.map +0 -1
  393. package/dist/lib/search-tool.d.ts +0 -55
  394. package/dist/lib/search-tool.js +0 -319
  395. package/dist/lib/search-tool.js.map +0 -1
  396. package/dist/lib/serve.d.ts +0 -11
  397. package/dist/lib/serve.js +0 -144
  398. package/dist/lib/serve.js.map +0 -1
  399. package/dist/lib/store.d.ts +0 -252
  400. package/dist/lib/store.js +0 -1216
  401. package/dist/lib/store.js.map +0 -1
  402. package/dist/lib/types.d.ts +0 -194
  403. package/dist/lib/types.js +0 -13
  404. package/dist/lib/types.js.map +0 -1
  405. package/dist/lib/vocab.d.ts +0 -20
  406. package/dist/lib/vocab.js +0 -275
  407. package/dist/lib/vocab.js.map +0 -1
  408. /package/dist/{lib/native-tuning.d.ts → infrastructure/lancedb/NativeTuning.d.ts} +0 -0
@@ -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,8BAA8B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAO5D;;;;;;;;GAQG;AACH,MAAM,OAAO,GAAG;IAWc;IAV7B,uEAAuE;IAC/D,MAAM,CAAU,MAAM,GAA+C;QAC5E,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,KAAK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,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;QACN,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAsB;QAChC,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACxB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,QAAQ,EAAE,OAAO,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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/presentation/cli/ConfigTemplate.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAc;IAC1B,MAAM,CAAC,MAAM,CAAC,QAA2B;QACxC,MAAM,SAAS,GAAG,QAAQ,EAAE,KAAK;YAChC,CAAC,CAAC,UAAU,QAAQ,CAAC,KAAK,EAAE;YAC5B,CAAC,CAAC,2DAA2D,CAAC;QAC/D,MAAM,WA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AAC,mBAAmB;;;EAGjF,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,cAAc,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,mBAAmB;CAC/E,CAAC;IACD,CAAC;CACD"}
@@ -0,0 +1,90 @@
1
+ import type { TidyReport } from "../../application/Lmgrep.js";
2
+ import type { Inventory } from "../../application/operations/IndexInventory.js";
3
+ import type { StatusInfo } from "../../application/operations/StatusService.js";
4
+ import type { ProjectIndex } from "../../domain/ports/ProjectIndexesPort.js";
5
+ import type { TraceEntry } from "../../domain/research/ResearchTrace.js";
6
+ import type { Hit } from "../../domain/retrieval/Hit.js";
7
+ import type { RunningProcess } from "../../infrastructure/process/ProcessRegistry.js";
8
+ /**
9
+ * All terminal output for the CLI.
10
+ *
11
+ * Separated from the commands so that what a command *does* and how it *reads*
12
+ * are independently changeable — the commands became testable the moment they
13
+ * stopped calling console.log directly.
14
+ */
15
+ export declare class Renderer {
16
+ private readonly out;
17
+ private static readonly RULE_WIDTH;
18
+ constructor(out?: (line: string) => void);
19
+ line(text?: string): void;
20
+ rule(): void;
21
+ json(value: unknown): void;
22
+ /**
23
+ * Full result view: a ruled header, the context block, then the source.
24
+ *
25
+ * The score is always shown. It used to be behind `--scores`, which meant
26
+ * the one number that says how much to trust a result was hidden by
27
+ * default and cost a flag to see.
28
+ */
29
+ hits(hits: readonly Hit[]): void;
30
+ /** Just the distinct file paths, in first-hit order. */
31
+ hitPaths(hits: readonly Hit[]): void;
32
+ /** One research step, written to stderr so stdout stays pipeable. */
33
+ static formatTrace(entry: TraceEntry): string;
34
+ /**
35
+ * The verdict, first and alone.
36
+ *
37
+ * Everything below it is detail for when the answer is "no". This line is
38
+ * the whole reason to run the command.
39
+ */
40
+ statusVerdict(info: StatusInfo): void;
41
+ /** Configuration and paths — shown even when there is no index yet. */
42
+ statusHeader(info: StatusInfo): void;
43
+ /**
44
+ * Which file supplied which settings.
45
+ *
46
+ * Worth a section of its own because the alternative is guessing. With two
47
+ * files able to set the same key, an effective value printed on its own
48
+ * tells you what lmgrep decided but not where to go to change it — which
49
+ * is the actual question when the answer surprises you.
50
+ */
51
+ statusConfig(info: StatusInfo): void;
52
+ statusStats(info: StatusInfo): void;
53
+ /**
54
+ * How searches are answered.
55
+ *
56
+ * Worth its own line because the difference is invisible otherwise: without
57
+ * an index every query scans every embedding, costing roughly the index's
58
+ * size in memory and an order of magnitude in latency. Nothing else tells
59
+ * the user that is happening.
60
+ */
61
+ private vectorIndex;
62
+ statusChecks(info: StatusInfo): void;
63
+ /** Who else is holding this index, and whether they are watching it. */
64
+ runningProcesses(processes: readonly RunningProcess[]): void;
65
+ /** Working-tree drift, truncated so a large diff stays readable. */
66
+ changes(changes: {
67
+ added: string[];
68
+ modified: string[];
69
+ deleted: string[];
70
+ }): void;
71
+ private changeGroup;
72
+ /**
73
+ * Warn that this run builds a *second* index for the project.
74
+ *
75
+ * Silent unless another model's index already exists, which is the only
76
+ * case where a full re-embed is about to happen for a reason the user may
77
+ * not have intended.
78
+ */
79
+ newModelNotice(others: readonly ProjectIndex[]): void;
80
+ /** What a maintenance pass changed; silent when it changed nothing. */
81
+ maintenance(report: TidyReport): void;
82
+ /**
83
+ * Every index on this machine.
84
+ *
85
+ * Sorted by size and leading with the total, because the question this
86
+ * answers is almost always "what is using my disk, and can I delete it".
87
+ */
88
+ inventory(inventory: Inventory): void;
89
+ error(message: string): void;
90
+ }