lmgrep 0.1.18 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (414) hide show
  1. package/README.md +253 -62
  2. package/completions/_lmgrep +49 -40
  3. package/dist/application/Lmgrep.d.ts +107 -0
  4. package/dist/application/Lmgrep.js +99 -0
  5. package/dist/application/Lmgrep.js.map +1 -0
  6. package/dist/application/LmgrepFactory.d.ts +40 -0
  7. package/dist/application/LmgrepFactory.js +155 -0
  8. package/dist/application/LmgrepFactory.js.map +1 -0
  9. package/dist/application/indexing/BranchBootstrapper.d.ts +21 -0
  10. package/dist/application/indexing/BranchBootstrapper.js +52 -0
  11. package/dist/application/indexing/BranchBootstrapper.js.map +1 -0
  12. package/dist/application/indexing/BranchManifestSweeper.d.ts +17 -0
  13. package/dist/application/indexing/BranchManifestSweeper.js +35 -0
  14. package/dist/application/indexing/BranchManifestSweeper.js.map +1 -0
  15. package/dist/application/indexing/Duration.d.ts +9 -0
  16. package/dist/application/indexing/Duration.js +25 -0
  17. package/dist/application/indexing/Duration.js.map +1 -0
  18. package/dist/application/indexing/EmbeddingAbortError.d.ts +11 -0
  19. package/dist/application/indexing/EmbeddingAbortError.js +20 -0
  20. package/dist/application/indexing/EmbeddingAbortError.js.map +1 -0
  21. package/dist/application/indexing/EmbeddingPipeline.d.ts +59 -0
  22. package/dist/application/indexing/EmbeddingPipeline.js +140 -0
  23. package/dist/application/indexing/EmbeddingPipeline.js.map +1 -0
  24. package/dist/application/indexing/IndexBuilder.d.ts +112 -0
  25. package/dist/application/indexing/IndexBuilder.js +370 -0
  26. package/dist/application/indexing/IndexBuilder.js.map +1 -0
  27. package/dist/application/indexing/IndexingProgress.d.ts +34 -0
  28. package/dist/application/indexing/IndexingProgress.js +2 -0
  29. package/dist/application/indexing/IndexingProgress.js.map +1 -0
  30. package/dist/application/operations/Deadline.d.ts +13 -0
  31. package/dist/application/operations/Deadline.js +29 -0
  32. package/dist/application/operations/Deadline.js.map +1 -0
  33. package/dist/application/operations/HealthMonitor.d.ts +58 -0
  34. package/dist/application/operations/HealthMonitor.js +128 -0
  35. package/dist/application/operations/HealthMonitor.js.map +1 -0
  36. package/dist/application/operations/IndexAlternatives.d.ts +35 -0
  37. package/dist/application/operations/IndexAlternatives.js +61 -0
  38. package/dist/application/operations/IndexAlternatives.js.map +1 -0
  39. package/dist/application/operations/IndexInventory.d.ts +69 -0
  40. package/dist/application/operations/IndexInventory.js +99 -0
  41. package/dist/application/operations/IndexInventory.js.map +1 -0
  42. package/dist/application/operations/StatusService.d.ts +90 -0
  43. package/dist/application/operations/StatusService.js +171 -0
  44. package/dist/application/operations/StatusService.js.map +1 -0
  45. package/dist/application/operations/WatchService.d.ts +67 -0
  46. package/dist/application/operations/WatchService.js +145 -0
  47. package/dist/application/operations/WatchService.js.map +1 -0
  48. package/dist/application/operations/WorkingTreeDiff.d.ts +19 -0
  49. package/dist/application/operations/WorkingTreeDiff.js +36 -0
  50. package/dist/application/operations/WorkingTreeDiff.js.map +1 -0
  51. package/dist/application/research/ResearchAgent.d.ts +68 -0
  52. package/dist/application/research/ResearchAgent.js +201 -0
  53. package/dist/application/research/ResearchAgent.js.map +1 -0
  54. package/dist/application/research/ResearchPrompts.d.ts +16 -0
  55. package/dist/application/research/ResearchPrompts.js +34 -0
  56. package/dist/application/research/ResearchPrompts.js.map +1 -0
  57. package/dist/application/search/SearchCriteria.d.ts +37 -0
  58. package/dist/application/search/SearchCriteria.js +48 -0
  59. package/dist/application/search/SearchCriteria.js.map +1 -0
  60. package/dist/application/search/SearchService.d.ts +36 -0
  61. package/dist/application/search/SearchService.js +108 -0
  62. package/dist/application/search/SearchService.js.map +1 -0
  63. package/dist/application/search/SearchTargetResolver.d.ts +56 -0
  64. package/dist/application/search/SearchTargetResolver.js +104 -0
  65. package/dist/application/search/SearchTargetResolver.js.map +1 -0
  66. package/dist/cli.d.ts +1 -1
  67. package/dist/cli.js +4 -953
  68. package/dist/cli.js.map +1 -1
  69. package/dist/domain/config/ConfigSource.d.ts +16 -0
  70. package/dist/domain/config/ConfigSource.js +2 -0
  71. package/dist/domain/config/ConfigSource.js.map +1 -0
  72. package/dist/domain/config/LmgrepConfig.d.ts +53 -0
  73. package/dist/domain/config/LmgrepConfig.js +2 -0
  74. package/dist/domain/config/LmgrepConfig.js.map +1 -0
  75. package/dist/domain/corpus/Chunk.d.ts +49 -0
  76. package/dist/domain/corpus/Chunk.js +60 -0
  77. package/dist/domain/corpus/Chunk.js.map +1 -0
  78. package/dist/domain/corpus/CodeLocation.d.ts +18 -0
  79. package/dist/domain/corpus/CodeLocation.js +34 -0
  80. package/dist/domain/corpus/CodeLocation.js.map +1 -0
  81. package/dist/domain/corpus/ContentHash.d.ts +15 -0
  82. package/dist/domain/corpus/ContentHash.js +30 -0
  83. package/dist/domain/corpus/ContentHash.js.map +1 -0
  84. package/dist/domain/corpus/FileVersion.d.ts +31 -0
  85. package/dist/domain/corpus/FileVersion.js +47 -0
  86. package/dist/domain/corpus/FileVersion.js.map +1 -0
  87. package/dist/domain/corpus/SourceFile.d.ts +26 -0
  88. package/dist/domain/corpus/SourceFile.js +47 -0
  89. package/dist/domain/corpus/SourceFile.js.map +1 -0
  90. package/dist/domain/corpus/Vector.d.ts +37 -0
  91. package/dist/domain/corpus/Vector.js +96 -0
  92. package/dist/domain/corpus/Vector.js.map +1 -0
  93. package/dist/domain/ports/ChatModelPort.d.ts +57 -0
  94. package/dist/domain/ports/ChatModelPort.js +2 -0
  95. package/dist/domain/ports/ChatModelPort.js.map +1 -0
  96. package/dist/domain/ports/ChunkRepositoryPort.d.ts +42 -0
  97. package/dist/domain/ports/ChunkRepositoryPort.js +2 -0
  98. package/dist/domain/ports/ChunkRepositoryPort.js.map +1 -0
  99. package/dist/domain/ports/ChunkerPort.d.ts +5 -0
  100. package/dist/domain/ports/ChunkerPort.js +2 -0
  101. package/dist/domain/ports/ChunkerPort.js.map +1 -0
  102. package/dist/domain/ports/DatabaseSessionPort.d.ts +10 -0
  103. package/dist/domain/ports/DatabaseSessionPort.js +2 -0
  104. package/dist/domain/ports/DatabaseSessionPort.js.map +1 -0
  105. package/dist/domain/ports/EmbedderPort.d.ts +14 -0
  106. package/dist/domain/ports/EmbedderPort.js +2 -0
  107. package/dist/domain/ports/EmbedderPort.js.map +1 -0
  108. package/dist/domain/ports/FileManifestRepositoryPort.d.ts +32 -0
  109. package/dist/domain/ports/FileManifestRepositoryPort.js +2 -0
  110. package/dist/domain/ports/FileManifestRepositoryPort.js.map +1 -0
  111. package/dist/domain/ports/GitPort.d.ts +24 -0
  112. package/dist/domain/ports/GitPort.js +2 -0
  113. package/dist/domain/ports/GitPort.js.map +1 -0
  114. package/dist/domain/ports/IndexMaintenancePort.d.ts +58 -0
  115. package/dist/domain/ports/IndexMaintenancePort.js +2 -0
  116. package/dist/domain/ports/IndexMaintenancePort.js.map +1 -0
  117. package/dist/domain/ports/IndexMetadataPort.d.ts +23 -0
  118. package/dist/domain/ports/IndexMetadataPort.js +2 -0
  119. package/dist/domain/ports/IndexMetadataPort.js.map +1 -0
  120. package/dist/domain/ports/LockPort.d.ts +17 -0
  121. package/dist/domain/ports/LockPort.js +2 -0
  122. package/dist/domain/ports/LockPort.js.map +1 -0
  123. package/dist/domain/ports/LoggerPort.d.ts +5 -0
  124. package/dist/domain/ports/LoggerPort.js +2 -0
  125. package/dist/domain/ports/LoggerPort.js.map +1 -0
  126. package/dist/domain/ports/ProjectIndexesPort.d.ts +20 -0
  127. package/dist/domain/ports/ProjectIndexesPort.js +2 -0
  128. package/dist/domain/ports/ProjectIndexesPort.js.map +1 -0
  129. package/dist/domain/ports/ProjectRegistryPort.d.ts +42 -0
  130. package/dist/domain/ports/ProjectRegistryPort.js +2 -0
  131. package/dist/domain/ports/ProjectRegistryPort.js.map +1 -0
  132. package/dist/domain/ports/StateDirectoryPort.d.ts +29 -0
  133. package/dist/domain/ports/StateDirectoryPort.js +2 -0
  134. package/dist/domain/ports/StateDirectoryPort.js.map +1 -0
  135. package/dist/domain/ports/WorkspacePort.d.ts +38 -0
  136. package/dist/domain/ports/WorkspacePort.js +2 -0
  137. package/dist/domain/ports/WorkspacePort.js.map +1 -0
  138. package/dist/domain/project/Branch.d.ts +20 -0
  139. package/dist/domain/project/Branch.js +33 -0
  140. package/dist/domain/project/Branch.js.map +1 -0
  141. package/dist/domain/project/DatabaseLocation.d.ts +32 -0
  142. package/dist/domain/project/DatabaseLocation.js +35 -0
  143. package/dist/domain/project/DatabaseLocation.js.map +1 -0
  144. package/dist/domain/project/IndexMetadata.d.ts +17 -0
  145. package/dist/domain/project/IndexMetadata.js +2 -0
  146. package/dist/domain/project/IndexMetadata.js.map +1 -0
  147. package/dist/domain/project/ModelIdentity.d.ts +58 -0
  148. package/dist/domain/project/ModelIdentity.js +94 -0
  149. package/dist/domain/project/ModelIdentity.js.map +1 -0
  150. package/dist/domain/project/Project.d.ts +17 -0
  151. package/dist/domain/project/Project.js +21 -0
  152. package/dist/domain/project/Project.js.map +1 -0
  153. package/dist/domain/project/ProjectId.d.ts +28 -0
  154. package/dist/domain/project/ProjectId.js +58 -0
  155. package/dist/domain/project/ProjectId.js.map +1 -0
  156. package/dist/domain/project/ProjectLocator.d.ts +112 -0
  157. package/dist/domain/project/ProjectLocator.js +178 -0
  158. package/dist/domain/project/ProjectLocator.js.map +1 -0
  159. package/dist/domain/research/Citation.d.ts +27 -0
  160. package/dist/domain/research/Citation.js +43 -0
  161. package/dist/domain/research/Citation.js.map +1 -0
  162. package/dist/domain/research/EvidenceLedger.d.ts +47 -0
  163. package/dist/domain/research/EvidenceLedger.js +111 -0
  164. package/dist/domain/research/EvidenceLedger.js.map +1 -0
  165. package/dist/domain/research/ResearchTrace.d.ts +19 -0
  166. package/dist/domain/research/ResearchTrace.js +22 -0
  167. package/dist/domain/research/ResearchTrace.js.map +1 -0
  168. package/dist/domain/retrieval/Hit.d.ts +19 -0
  169. package/dist/domain/retrieval/Hit.js +28 -0
  170. package/dist/domain/retrieval/Hit.js.map +1 -0
  171. package/dist/domain/retrieval/HitList.d.ts +35 -0
  172. package/dist/domain/retrieval/HitList.js +81 -0
  173. package/dist/domain/retrieval/HitList.js.map +1 -0
  174. package/dist/domain/retrieval/MissingIndexError.d.ts +11 -0
  175. package/dist/domain/retrieval/MissingIndexError.js +15 -0
  176. package/dist/domain/retrieval/MissingIndexError.js.map +1 -0
  177. package/dist/index.d.ts +43 -45
  178. package/dist/index.js +30 -567
  179. package/dist/index.js.map +1 -1
  180. package/dist/infrastructure/ai/AiSdkChatModel.d.ts +31 -0
  181. package/dist/infrastructure/ai/AiSdkChatModel.js +137 -0
  182. package/dist/infrastructure/ai/AiSdkChatModel.js.map +1 -0
  183. package/dist/infrastructure/ai/AiSdkEmbedder.d.ts +28 -0
  184. package/dist/infrastructure/ai/AiSdkEmbedder.js +79 -0
  185. package/dist/infrastructure/ai/AiSdkEmbedder.js.map +1 -0
  186. package/dist/infrastructure/ai/DockerModelRunnerProbe.d.ts +16 -0
  187. package/dist/infrastructure/ai/DockerModelRunnerProbe.js +52 -0
  188. package/dist/infrastructure/ai/DockerModelRunnerProbe.js.map +1 -0
  189. package/dist/infrastructure/ai/EmbeddingPrefixes.d.ts +21 -0
  190. package/dist/infrastructure/ai/EmbeddingPrefixes.js +40 -0
  191. package/dist/infrastructure/ai/EmbeddingPrefixes.js.map +1 -0
  192. package/dist/infrastructure/ai/LmStudioProbe.d.ts +18 -0
  193. package/dist/infrastructure/ai/LmStudioProbe.js +49 -0
  194. package/dist/infrastructure/ai/LmStudioProbe.js.map +1 -0
  195. package/dist/infrastructure/ai/LocalModelReloader.d.ts +21 -0
  196. package/dist/infrastructure/ai/LocalModelReloader.js +61 -0
  197. package/dist/infrastructure/ai/LocalModelReloader.js.map +1 -0
  198. package/dist/infrastructure/ai/LocalRuntimeDetector.d.ts +36 -0
  199. package/dist/infrastructure/ai/LocalRuntimeDetector.js +63 -0
  200. package/dist/infrastructure/ai/LocalRuntimeDetector.js.map +1 -0
  201. package/dist/infrastructure/ai/ModelRuntime.d.ts +32 -0
  202. package/dist/infrastructure/ai/ModelRuntime.js +2 -0
  203. package/dist/infrastructure/ai/ModelRuntime.js.map +1 -0
  204. package/dist/infrastructure/ai/OllamaProbe.d.ts +22 -0
  205. package/dist/infrastructure/ai/OllamaProbe.js +71 -0
  206. package/dist/infrastructure/ai/OllamaProbe.js.map +1 -0
  207. package/dist/infrastructure/ai/ProviderFailure.d.ts +16 -0
  208. package/dist/infrastructure/ai/ProviderFailure.js +35 -0
  209. package/dist/infrastructure/ai/ProviderFailure.js.map +1 -0
  210. package/dist/infrastructure/ai/ProviderModuleLoader.d.ts +14 -0
  211. package/dist/infrastructure/ai/ProviderModuleLoader.js +56 -0
  212. package/dist/infrastructure/ai/ProviderModuleLoader.js.map +1 -0
  213. package/dist/infrastructure/ai/ProviderRegistry.d.ts +38 -0
  214. package/dist/infrastructure/ai/ProviderRegistry.js +63 -0
  215. package/dist/infrastructure/ai/ProviderRegistry.js.map +1 -0
  216. package/dist/infrastructure/fs/ConfigLoader.d.ts +59 -0
  217. package/dist/infrastructure/fs/ConfigLoader.js +194 -0
  218. package/dist/infrastructure/fs/ConfigLoader.js.map +1 -0
  219. package/dist/infrastructure/fs/DatabaseLocks.d.ts +52 -0
  220. package/dist/infrastructure/fs/DatabaseLocks.js +92 -0
  221. package/dist/infrastructure/fs/DatabaseLocks.js.map +1 -0
  222. package/dist/infrastructure/fs/DiskUsage.d.ts +6 -0
  223. package/dist/infrastructure/fs/DiskUsage.js +41 -0
  224. package/dist/infrastructure/fs/DiskUsage.js.map +1 -0
  225. package/dist/infrastructure/fs/IndexableFileRules.d.ts +33 -0
  226. package/dist/infrastructure/fs/IndexableFileRules.js +177 -0
  227. package/dist/infrastructure/fs/IndexableFileRules.js.map +1 -0
  228. package/dist/infrastructure/fs/Loggers.d.ts +14 -0
  229. package/dist/infrastructure/fs/Loggers.js +18 -0
  230. package/dist/infrastructure/fs/Loggers.js.map +1 -0
  231. package/dist/infrastructure/fs/PidFileLock.d.ts +40 -0
  232. package/dist/infrastructure/fs/PidFileLock.js +97 -0
  233. package/dist/infrastructure/fs/PidFileLock.js.map +1 -0
  234. package/dist/infrastructure/fs/ProjectIndexes.d.ts +8 -0
  235. package/dist/infrastructure/fs/ProjectIndexes.js +35 -0
  236. package/dist/infrastructure/fs/ProjectIndexes.js.map +1 -0
  237. package/dist/infrastructure/fs/ProjectMetadataStore.d.ts +42 -0
  238. package/dist/infrastructure/fs/ProjectMetadataStore.js +86 -0
  239. package/dist/infrastructure/fs/ProjectMetadataStore.js.map +1 -0
  240. package/dist/infrastructure/fs/ProjectRegistry.d.ts +25 -0
  241. package/dist/infrastructure/fs/ProjectRegistry.js +83 -0
  242. package/dist/infrastructure/fs/ProjectRegistry.js.map +1 -0
  243. package/dist/infrastructure/fs/StateDirectory.d.ts +28 -0
  244. package/dist/infrastructure/fs/StateDirectory.js +71 -0
  245. package/dist/infrastructure/fs/StateDirectory.js.map +1 -0
  246. package/dist/infrastructure/fs/Workspace.d.ts +25 -0
  247. package/dist/infrastructure/fs/Workspace.js +90 -0
  248. package/dist/infrastructure/fs/Workspace.js.map +1 -0
  249. package/dist/infrastructure/git/GitClient.d.ts +34 -0
  250. package/dist/infrastructure/git/GitClient.js +74 -0
  251. package/dist/infrastructure/git/GitClient.js.map +1 -0
  252. package/dist/infrastructure/lancedb/ChunkRepository.d.ts +38 -0
  253. package/dist/infrastructure/lancedb/ChunkRepository.js +166 -0
  254. package/dist/infrastructure/lancedb/ChunkRepository.js.map +1 -0
  255. package/dist/infrastructure/lancedb/DatabaseImporter.d.ts +22 -0
  256. package/dist/infrastructure/lancedb/DatabaseImporter.js +74 -0
  257. package/dist/infrastructure/lancedb/DatabaseImporter.js.map +1 -0
  258. package/dist/infrastructure/lancedb/FileManifestRepository.d.ts +34 -0
  259. package/dist/infrastructure/lancedb/FileManifestRepository.js +137 -0
  260. package/dist/infrastructure/lancedb/FileManifestRepository.js.map +1 -0
  261. package/dist/infrastructure/lancedb/IndexMaintenance.d.ts +53 -0
  262. package/dist/infrastructure/lancedb/IndexMaintenance.js +227 -0
  263. package/dist/infrastructure/lancedb/IndexMaintenance.js.map +1 -0
  264. package/dist/infrastructure/lancedb/LanceTables.d.ts +67 -0
  265. package/dist/infrastructure/lancedb/LanceTables.js +159 -0
  266. package/dist/infrastructure/lancedb/LanceTables.js.map +1 -0
  267. package/dist/{lib/native-tuning.js → infrastructure/lancedb/NativeTuning.js} +1 -1
  268. package/dist/infrastructure/lancedb/NativeTuning.js.map +1 -0
  269. package/dist/infrastructure/lancedb/RowReplication.d.ts +27 -0
  270. package/dist/infrastructure/lancedb/RowReplication.js +82 -0
  271. package/dist/infrastructure/lancedb/RowReplication.js.map +1 -0
  272. package/dist/infrastructure/lancedb/VectorIndexPolicy.d.ts +60 -0
  273. package/dist/infrastructure/lancedb/VectorIndexPolicy.js +72 -0
  274. package/dist/infrastructure/lancedb/VectorIndexPolicy.js.map +1 -0
  275. package/dist/infrastructure/p2p/IndexShare.d.ts +45 -0
  276. package/dist/infrastructure/p2p/IndexShare.js +160 -0
  277. package/dist/infrastructure/p2p/IndexShare.js.map +1 -0
  278. package/dist/infrastructure/p2p/PeerSwarm.d.ts +16 -0
  279. package/dist/infrastructure/p2p/PeerSwarm.js +41 -0
  280. package/dist/infrastructure/p2p/PeerSwarm.js.map +1 -0
  281. package/dist/infrastructure/p2p/SecureChannel.d.ts +60 -0
  282. package/dist/infrastructure/p2p/SecureChannel.js +71 -0
  283. package/dist/infrastructure/p2p/SecureChannel.js.map +1 -0
  284. package/dist/infrastructure/p2p/ShareCode.d.ts +25 -0
  285. package/dist/infrastructure/p2p/ShareCode.js +304 -0
  286. package/dist/infrastructure/p2p/ShareCode.js.map +1 -0
  287. package/dist/infrastructure/process/ProcessRegistry.d.ts +50 -0
  288. package/dist/infrastructure/process/ProcessRegistry.js +109 -0
  289. package/dist/infrastructure/process/ProcessRegistry.js.map +1 -0
  290. package/dist/infrastructure/treesitter/ChunkContextBuilder.d.ts +45 -0
  291. package/dist/infrastructure/treesitter/ChunkContextBuilder.js +159 -0
  292. package/dist/infrastructure/treesitter/ChunkContextBuilder.js.map +1 -0
  293. package/dist/infrastructure/treesitter/EmbeddedTreeSitterAssets.d.ts +8 -0
  294. package/dist/infrastructure/treesitter/EmbeddedTreeSitterAssets.js +12 -0
  295. package/dist/infrastructure/treesitter/EmbeddedTreeSitterAssets.js.map +1 -0
  296. package/dist/infrastructure/treesitter/LanguageCatalog.d.ts +30 -0
  297. package/dist/{lib/chunker/languages.js → infrastructure/treesitter/LanguageCatalog.js} +38 -29
  298. package/dist/infrastructure/treesitter/LanguageCatalog.js.map +1 -0
  299. package/dist/infrastructure/treesitter/SlidingWindowChunker.d.ts +15 -0
  300. package/dist/infrastructure/treesitter/SlidingWindowChunker.js +42 -0
  301. package/dist/infrastructure/treesitter/SlidingWindowChunker.js.map +1 -0
  302. package/dist/infrastructure/treesitter/TreeSitterChunker.d.ts +42 -0
  303. package/dist/infrastructure/treesitter/TreeSitterChunker.js +165 -0
  304. package/dist/infrastructure/treesitter/TreeSitterChunker.js.map +1 -0
  305. package/dist/mcp.d.ts +1 -1
  306. package/dist/mcp.js +14 -72
  307. package/dist/mcp.js.map +1 -1
  308. package/dist/presentation/cli/Cli.d.ts +31 -0
  309. package/dist/presentation/cli/Cli.js +120 -0
  310. package/dist/presentation/cli/Cli.js.map +1 -0
  311. package/dist/presentation/cli/CliOptions.d.ts +18 -0
  312. package/dist/presentation/cli/CliOptions.js +25 -0
  313. package/dist/presentation/cli/CliOptions.js.map +1 -0
  314. package/dist/presentation/cli/CommandContext.d.ts +50 -0
  315. package/dist/presentation/cli/CommandContext.js +88 -0
  316. package/dist/presentation/cli/CommandContext.js.map +1 -0
  317. package/dist/presentation/cli/ConfigTemplate.d.ts +31 -0
  318. package/dist/presentation/cli/ConfigTemplate.js +83 -0
  319. package/dist/presentation/cli/ConfigTemplate.js.map +1 -0
  320. package/dist/presentation/cli/Renderer.d.ts +90 -0
  321. package/dist/presentation/cli/Renderer.js +290 -0
  322. package/dist/presentation/cli/Renderer.js.map +1 -0
  323. package/dist/presentation/cli/commands/AskCommand.d.ts +14 -0
  324. package/dist/presentation/cli/commands/AskCommand.js +48 -0
  325. package/dist/presentation/cli/commands/AskCommand.js.map +1 -0
  326. package/dist/presentation/cli/commands/CompletionsCommand.d.ts +18 -0
  327. package/dist/presentation/cli/commands/CompletionsCommand.js +96 -0
  328. package/dist/presentation/cli/commands/CompletionsCommand.js.map +1 -0
  329. package/dist/presentation/cli/commands/ConfigCommands.d.ts +56 -0
  330. package/dist/presentation/cli/commands/ConfigCommands.js +220 -0
  331. package/dist/presentation/cli/commands/ConfigCommands.js.map +1 -0
  332. package/dist/presentation/cli/commands/IndexCommand.d.ts +18 -0
  333. package/dist/presentation/cli/commands/IndexCommand.js +54 -0
  334. package/dist/presentation/cli/commands/IndexCommand.js.map +1 -0
  335. package/dist/presentation/cli/commands/ProjectsCommand.d.ts +48 -0
  336. package/dist/presentation/cli/commands/ProjectsCommand.js +240 -0
  337. package/dist/presentation/cli/commands/ProjectsCommand.js.map +1 -0
  338. package/dist/presentation/cli/commands/SearchCommand.d.ts +19 -0
  339. package/dist/presentation/cli/commands/SearchCommand.js +55 -0
  340. package/dist/presentation/cli/commands/SearchCommand.js.map +1 -0
  341. package/dist/presentation/cli/commands/ServerCommands.d.ts +13 -0
  342. package/dist/presentation/cli/commands/ServerCommands.js +40 -0
  343. package/dist/presentation/cli/commands/ServerCommands.js.map +1 -0
  344. package/dist/presentation/cli/commands/ShareCommands.d.ts +22 -0
  345. package/dist/presentation/cli/commands/ShareCommands.js +134 -0
  346. package/dist/presentation/cli/commands/ShareCommands.js.map +1 -0
  347. package/dist/presentation/cli/commands/StatusCommand.d.ts +15 -0
  348. package/dist/presentation/cli/commands/StatusCommand.js +53 -0
  349. package/dist/presentation/cli/commands/StatusCommand.js.map +1 -0
  350. package/dist/presentation/mcp/HitFormatter.d.ts +17 -0
  351. package/dist/presentation/mcp/HitFormatter.js +42 -0
  352. package/dist/presentation/mcp/HitFormatter.js.map +1 -0
  353. package/dist/presentation/mcp/IndexWatchController.d.ts +17 -0
  354. package/dist/presentation/mcp/IndexWatchController.js +31 -0
  355. package/dist/presentation/mcp/IndexWatchController.js.map +1 -0
  356. package/dist/presentation/mcp/LmgrepCore.d.ts +66 -0
  357. package/dist/presentation/mcp/LmgrepCore.js +178 -0
  358. package/dist/presentation/mcp/LmgrepCore.js.map +1 -0
  359. package/dist/presentation/mcp/McpServer.d.ts +18 -0
  360. package/dist/presentation/mcp/McpServer.js +63 -0
  361. package/dist/presentation/mcp/McpServer.js.map +1 -0
  362. package/dist/presentation/mcp/ToolDescriptions.d.ts +40 -0
  363. package/dist/presentation/mcp/ToolDescriptions.js +85 -0
  364. package/dist/presentation/mcp/ToolDescriptions.js.map +1 -0
  365. package/package.json +93 -89
  366. package/dist/lib/build.d.ts +0 -21
  367. package/dist/lib/build.js +0 -374
  368. package/dist/lib/build.js.map +0 -1
  369. package/dist/lib/chunker/context.d.ts +0 -21
  370. package/dist/lib/chunker/context.js +0 -131
  371. package/dist/lib/chunker/context.js.map +0 -1
  372. package/dist/lib/chunker/index.d.ts +0 -7
  373. package/dist/lib/chunker/index.js +0 -209
  374. package/dist/lib/chunker/index.js.map +0 -1
  375. package/dist/lib/chunker/languages.d.ts +0 -15
  376. package/dist/lib/chunker/languages.js.map +0 -1
  377. package/dist/lib/config.d.ts +0 -12
  378. package/dist/lib/config.js +0 -83
  379. package/dist/lib/config.js.map +0 -1
  380. package/dist/lib/embedder.d.ts +0 -65
  381. package/dist/lib/embedder.js +0 -236
  382. package/dist/lib/embedder.js.map +0 -1
  383. package/dist/lib/facet-session.d.ts +0 -44
  384. package/dist/lib/facet-session.js +0 -125
  385. package/dist/lib/facet-session.js.map +0 -1
  386. package/dist/lib/native-tuning.js.map +0 -1
  387. package/dist/lib/p2p.d.ts +0 -32
  388. package/dist/lib/p2p.js +0 -281
  389. package/dist/lib/p2p.js.map +0 -1
  390. package/dist/lib/providers.d.ts +0 -1
  391. package/dist/lib/providers.js +0 -41
  392. package/dist/lib/providers.js.map +0 -1
  393. package/dist/lib/repair.d.ts +0 -10
  394. package/dist/lib/repair.js +0 -57
  395. package/dist/lib/repair.js.map +0 -1
  396. package/dist/lib/scanner.d.ts +0 -34
  397. package/dist/lib/scanner.js +0 -242
  398. package/dist/lib/scanner.js.map +0 -1
  399. package/dist/lib/search-tool.d.ts +0 -55
  400. package/dist/lib/search-tool.js +0 -319
  401. package/dist/lib/search-tool.js.map +0 -1
  402. package/dist/lib/serve.d.ts +0 -11
  403. package/dist/lib/serve.js +0 -144
  404. package/dist/lib/serve.js.map +0 -1
  405. package/dist/lib/store.d.ts +0 -252
  406. package/dist/lib/store.js +0 -1216
  407. package/dist/lib/store.js.map +0 -1
  408. package/dist/lib/types.d.ts +0 -194
  409. package/dist/lib/types.js +0 -13
  410. package/dist/lib/types.js.map +0 -1
  411. package/dist/lib/vocab.d.ts +0 -20
  412. package/dist/lib/vocab.js +0 -275
  413. package/dist/lib/vocab.js.map +0 -1
  414. /package/dist/{lib/native-tuning.d.ts → infrastructure/lancedb/NativeTuning.d.ts} +0 -0
@@ -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
+ }
@@ -0,0 +1,290 @@
1
+ import { DiskUsage } from "../../infrastructure/fs/DiskUsage.js";
2
+ /**
3
+ * All terminal output for the CLI.
4
+ *
5
+ * Separated from the commands so that what a command *does* and how it *reads*
6
+ * are independently changeable — the commands became testable the moment they
7
+ * stopped calling console.log directly.
8
+ */
9
+ export class Renderer {
10
+ out;
11
+ static RULE_WIDTH = 60;
12
+ constructor(out = console.log) {
13
+ this.out = out;
14
+ }
15
+ line(text = "") {
16
+ this.out(text);
17
+ }
18
+ rule() {
19
+ this.out("─".repeat(Renderer.RULE_WIDTH));
20
+ }
21
+ json(value) {
22
+ this.out(JSON.stringify(value, null, 2));
23
+ }
24
+ /**
25
+ * Full result view: a ruled header, the context block, then the source.
26
+ *
27
+ * The score is always shown. It used to be behind `--scores`, which meant
28
+ * the one number that says how much to trust a result was hidden by
29
+ * default and cost a flag to see.
30
+ */
31
+ hits(hits) {
32
+ for (const hit of hits) {
33
+ const score = ` (${hit.score.toFixed(3)})`;
34
+ this.out(`\n${"─".repeat(Renderer.RULE_WIDTH)}`);
35
+ this.out(`${hit.location} [${hit.type}] ${hit.name}${score}`);
36
+ this.rule();
37
+ this.out(hit.context);
38
+ this.out("");
39
+ this.out(hit.content);
40
+ }
41
+ }
42
+ /** Just the distinct file paths, in first-hit order. */
43
+ hitPaths(hits) {
44
+ const seen = new Set();
45
+ for (const hit of hits) {
46
+ if (seen.has(hit.location.filePath))
47
+ continue;
48
+ seen.add(hit.location.filePath);
49
+ this.out(hit.location.filePath);
50
+ }
51
+ }
52
+ /** One research step, written to stderr so stdout stays pipeable. */
53
+ static formatTrace(entry) {
54
+ return entry.kind === "search"
55
+ ? ` search "${entry.query}" → ${entry.hits} hits`
56
+ : ` · ${entry.message}`;
57
+ }
58
+ /**
59
+ * The verdict, first and alone.
60
+ *
61
+ * Everything below it is detail for when the answer is "no". This line is
62
+ * the whole reason to run the command.
63
+ */
64
+ statusVerdict(info) {
65
+ if (!info.verdict.searchable) {
66
+ this.out(`Not searchable — ${info.verdict.reason}`);
67
+ this.out(` Fix: ${info.verdict.fix}`);
68
+ return;
69
+ }
70
+ this.out("Searchable.");
71
+ if (info.verdict.note)
72
+ this.out(` Note: ${info.verdict.note}`);
73
+ }
74
+ /** Configuration and paths — shown even when there is no index yet. */
75
+ statusHeader(info) {
76
+ this.out(`\nProject: ${info.projectRoot}`);
77
+ if (info.prefix)
78
+ this.out(`Subdirectory: ${info.prefix}`);
79
+ this.out(`Index: ${info.databasePath}`);
80
+ this.out(`Model: ${info.config.model}`);
81
+ if (info.config.baseURL)
82
+ this.out(`Server: ${info.config.baseURL}`);
83
+ }
84
+ /**
85
+ * Which file supplied which settings.
86
+ *
87
+ * Worth a section of its own because the alternative is guessing. With two
88
+ * files able to set the same key, an effective value printed on its own
89
+ * tells you what lmgrep decided but not where to go to change it — which
90
+ * is the actual question when the answer surprises you.
91
+ */
92
+ statusConfig(info) {
93
+ this.out("\nConfiguration:");
94
+ if (info.configSources.length === 0) {
95
+ this.out(" (none — defaults only)");
96
+ return;
97
+ }
98
+ for (const source of info.configSources) {
99
+ const marks = [
100
+ source.scope === "project" ? "project" : "machine",
101
+ source.deprecated ? "deprecated location" : undefined,
102
+ ].filter(Boolean);
103
+ this.out(` ${source.path} [${marks.join(", ")}]`);
104
+ this.out(` ${source.keys.join(", ") || "(nothing applied)"}`);
105
+ }
106
+ if (info.configSources.length > 1) {
107
+ this.out(" Later files override earlier ones, key by key.");
108
+ }
109
+ }
110
+ statusStats(info) {
111
+ this.out("\nIndex stats:");
112
+ this.out(` Files: ${info.fileCount}`);
113
+ this.out(` Chunks: ${info.chunkCount}`);
114
+ this.out(` Unique hashes: ${info.uniqueHashes}`);
115
+ if (info.indexModel)
116
+ this.out(` Index model: ${info.indexModel}`);
117
+ if (info.indexDimensions) {
118
+ this.out(` Dimensions: ${info.indexDimensions}`);
119
+ }
120
+ // A gap between rows and distinct hashes means duplicate chunks, which
121
+ // `lmgrep compact` removes.
122
+ if (info.chunkCount !== info.uniqueHashes) {
123
+ this.out(` Duplicates: ${info.chunkCount - info.uniqueHashes}`);
124
+ }
125
+ this.vectorIndex(info.vectorIndex);
126
+ }
127
+ /**
128
+ * How searches are answered.
129
+ *
130
+ * Worth its own line because the difference is invisible otherwise: without
131
+ * an index every query scans every embedding, costing roughly the index's
132
+ * size in memory and an order of magnitude in latency. Nothing else tells
133
+ * the user that is happening.
134
+ */
135
+ vectorIndex(state) {
136
+ if (state.built) {
137
+ this.out(state.unindexed > 0
138
+ ? ` Vector index: yes (${state.unindexed} rows awaiting the next optimize)`
139
+ : " Vector index: yes");
140
+ return;
141
+ }
142
+ if (!state.worthBuilding) {
143
+ this.out(" Vector index: not needed at this size");
144
+ return;
145
+ }
146
+ this.out(" Vector index: MISSING — every search scans all " +
147
+ `${state.rows} embeddings. Run \`lmgrep index\` to build it.`);
148
+ }
149
+ statusChecks(info) {
150
+ this.out("\nEmbedding check:");
151
+ if (info.embeddingOk) {
152
+ this.out(` OK (${info.embeddingLatencyMs}ms)`);
153
+ }
154
+ else {
155
+ this.out(" FAILED");
156
+ for (const line of (info.embeddingError ?? "").split("\n")) {
157
+ if (info.embeddingError)
158
+ this.out(` ${line}`);
159
+ }
160
+ }
161
+ this.out("\nSearch check:");
162
+ if (info.searchOk) {
163
+ this.out(` OK (${info.searchResultCount} result, ${info.searchLatencyMs}ms)`);
164
+ }
165
+ else if (info.embeddingOk && info.fileCount > 0) {
166
+ this.out(" FAILED (query returned no results)");
167
+ }
168
+ else {
169
+ this.out(" SKIPPED");
170
+ }
171
+ }
172
+ /** Who else is holding this index, and whether they are watching it. */
173
+ runningProcesses(processes) {
174
+ if (processes.length === 0) {
175
+ this.out("\nNo running lmgrep processes.");
176
+ return;
177
+ }
178
+ this.out("\nRunning processes:");
179
+ for (const proc of processes) {
180
+ const label = proc.kind === "mcp"
181
+ ? "MCP server"
182
+ : proc.kind === "serve"
183
+ ? "serve"
184
+ : "CLI";
185
+ this.out(` ${label} (pid ${proc.pid})${proc.watching ? ", watching" : ""}`);
186
+ this.out(` project: ${proc.projectRoot ?? "unknown"}`);
187
+ if (proc.databasePath)
188
+ this.out(` index: ${proc.databasePath}`);
189
+ }
190
+ }
191
+ /** Working-tree drift, truncated so a large diff stays readable. */
192
+ changes(changes) {
193
+ const total = changes.added.length + changes.modified.length + changes.deleted.length;
194
+ if (total === 0) {
195
+ this.out(" No changes detected.");
196
+ return;
197
+ }
198
+ this.changeGroup("Added", "+", changes.added);
199
+ this.changeGroup("Modified", "~", changes.modified);
200
+ this.changeGroup("Deleted", "-", changes.deleted);
201
+ this.out("\n Run `lmgrep index` to update the index.");
202
+ }
203
+ changeGroup(label, marker, files) {
204
+ if (files.length === 0)
205
+ return;
206
+ const SHOWN = 10;
207
+ this.out(` ${label}: ${files.length}`);
208
+ for (const f of files.slice(0, SHOWN))
209
+ this.out(` ${marker} ${f}`);
210
+ if (files.length > SHOWN) {
211
+ this.out(` ... and ${files.length - SHOWN} more`);
212
+ }
213
+ }
214
+ /**
215
+ * Warn that this run builds a *second* index for the project.
216
+ *
217
+ * Silent unless another model's index already exists, which is the only
218
+ * case where a full re-embed is about to happen for a reason the user may
219
+ * not have intended.
220
+ */
221
+ newModelNotice(others) {
222
+ if (others.length === 0)
223
+ return;
224
+ this.out("This project is already indexed with " +
225
+ others
226
+ .map((o) => `${o.model ?? "an unrecorded model"} (${DiskUsage.format(o.bytes)})`)
227
+ .join(", "));
228
+ this.out("Embedding it again under the newly configured model. The existing index is kept —");
229
+ this.out("setting `model` back returns to it instantly. `lmgrep projects` lists both.\n");
230
+ }
231
+ /** What a maintenance pass changed; silent when it changed nothing. */
232
+ maintenance(report) {
233
+ const { duplicateIds, staleVersions, before, after } = report.deduped;
234
+ if (duplicateIds + staleVersions > 0) {
235
+ this.out(`Removed ${duplicateIds} duplicate and ${staleVersions} superseded chunks (${before} → ${after}).`);
236
+ }
237
+ for (const table of report.optimized.tables) {
238
+ if (table.action === "created") {
239
+ this.out(`Built vector index on ${table.table} (${table.rows} rows).`);
240
+ }
241
+ else if (table.action === "dropped") {
242
+ this.out(`Dropped the unused ${table.table} table (${table.rows} rows).`);
243
+ }
244
+ }
245
+ }
246
+ /**
247
+ * Every index on this machine.
248
+ *
249
+ * Sorted by size and leading with the total, because the question this
250
+ * answers is almost always "what is using my disk, and can I delete it".
251
+ */
252
+ inventory(inventory) {
253
+ if (inventory.entries.length === 0) {
254
+ this.out("No indexes on this machine yet. Run `lmgrep index` in a project.");
255
+ return;
256
+ }
257
+ for (const entry of inventory.entries) {
258
+ const marks = [
259
+ entry.kind === "legacy" ? "legacy" : undefined,
260
+ entry.name ? "standalone" : undefined,
261
+ entry.state === "orphaned" ? "project gone" : undefined,
262
+ entry.state === "unattributable" ? "unattributable" : undefined,
263
+ ].filter(Boolean);
264
+ this.out(`${DiskUsage.format(entry.bytes).padStart(7)} ${entry.name ?? entry.root ?? "(unknown project)"}` +
265
+ (marks.length > 0 ? ` [${marks.join(", ")}]` : ""));
266
+ this.out(` ${entry.model ?? "unknown model"}${entry.dimensions ? ` · ${entry.dimensions} dims` : ""}`);
267
+ this.out(` ${entry.databasePath}`);
268
+ }
269
+ this.out(`\n${inventory.entries.length} index(es), ${DiskUsage.format(inventory.totalBytes)} total.`);
270
+ const legacy = inventory.entries.filter((e) => e.kind === "legacy").length;
271
+ const dead = inventory.entries.filter((e) => e.state === "orphaned").length;
272
+ const unknown = inventory.entries.filter((e) => e.state === "unattributable").length;
273
+ if (legacy > 0) {
274
+ this.out(`${legacy} still in the state directory — run \`lmgrep projects adopt\` in each project to move them in.`);
275
+ }
276
+ if (dead > 0) {
277
+ this.out(`${dead} whose project no longer exists — \`lmgrep projects gc\` reclaims them.`);
278
+ }
279
+ if (unknown > 0) {
280
+ this.out(`${unknown} record no project — \`lmgrep projects gc --unknown\` includes them.`);
281
+ }
282
+ if (inventory.dangling > 0) {
283
+ this.out(`${inventory.dangling} stale pointer(s) to deleted indexes — \`lmgrep projects gc\` forgets them.`);
284
+ }
285
+ }
286
+ error(message) {
287
+ console.error(message);
288
+ }
289
+ }
290
+ //# sourceMappingURL=Renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Renderer.js","sourceRoot":"","sources":["../../../src/presentation/cli/Renderer.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE;;;;;;GAMG;AACH,MAAM,OAAO,QAAQ;IAGS;IAFrB,MAAM,CAAU,UAAU,GAAG,EAAE,CAAC;IAExC,YAA6B,MAA8B,OAAO,CAAC,GAAG;QAAzC,QAAG,GAAH,GAAG,CAAsC;IAAG,CAAC;IAE1E,IAAI,CAAC,IAAI,GAAG,EAAE;QACb,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAED,IAAI;QACH,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,CAAC,KAAc;QAClB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,IAAI,CAAC,IAAoB;QACxB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;YAC3C,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;Y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C,KAAK,KAAK,UAAU,CAAC,CAAC,MAAM,CAAC;QAC5E,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CACvC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,gBAAgB,CACnC,CAAC,MAAM,CAAC;QACT,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YAChB,IAAI,CAAC,GAAG,CACP,GAAG,MAAM,gGAAgG,CACzG,CAAC;QACH,CAAC;QACD,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;YACd,IAAI,CAAC,GAAG,CACP,GAAG,IAAI,yEAAyE,CAChF,CAAC;QACH,CAAC;QACD,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,GAAG,CACP,GAAG,OAAO,sEAAsE,CAChF,CAAC;QACH,CAAC;QACD,IAAI,SAAS,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,CACP,GAAG,SAAS,CAAC,QAAQ,6EAA6E,CAClG,CAAC;QACH,CAAC;IACF,CAAC;IAED,KAAK,CAAC,OAAe;QACpB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Command } from "commander";
2
+ import type { CommandContext } from "../CommandContext.js";
3
+ /**
4
+ * `lmgrep ask` — a synthesized, cited answer.
5
+ *
6
+ * The live trace goes to stderr and the answer to stdout, so the command stays
7
+ * pipeable while still showing progress on a run that can take minutes.
8
+ */
9
+ export declare class AskCommand {
10
+ private readonly context;
11
+ constructor(context: CommandContext);
12
+ register(program: Command): void;
13
+ private run;
14
+ }
@@ -0,0 +1,48 @@
1
+ import { CliOptions } from "../CliOptions.js";
2
+ import { Renderer } from "../Renderer.js";
3
+ /**
4
+ * `lmgrep ask` — a synthesized, cited answer.
5
+ *
6
+ * The live trace goes to stderr and the answer to stdout, so the command stays
7
+ * pipeable while still showing progress on a run that can take minutes.
8
+ */
9
+ export class AskCommand {
10
+ context;
11
+ constructor(context) {
12
+ this.context = context;
13
+ }
14
+ register(program) {
15
+ CliOptions.target(program
16
+ .command("ask <question...>")
17
+ .description("Answer a question with a local research loop (search, read, synthesize)")
18
+ .option("--json", "Print the full result (answer, sources, trace) as JSON")
19
+ .option("--quiet", "Suppress the live research trace on stderr")).action((question, options) => this.run(question.join(" "), options));
20
+ }
21
+ async run(question, options) {
22
+ const { renderer } = this.context;
23
+ await this.context.withLmgrep(options, async (lmgrep) => {
24
+ const result = await lmgrep.ask(question, options.quiet
25
+ ? undefined
26
+ : (entry) => process.stderr.write(`${Renderer.formatTrace(entry)}\n`));
27
+ if (options.json) {
28
+ renderer.json(result);
29
+ return;
30
+ }
31
+ if (!options.quiet)
32
+ process.stderr.write("\n");
33
+ renderer.line(result.answer);
34
+ if (result.sources.length > 0) {
35
+ renderer.line("\nSources:");
36
+ for (const s of result.sources) {
37
+ renderer.line(` [${s.n}] ${s.path}:${s.startLine}-${s.endLine}`);
38
+ }
39
+ }
40
+ const seconds = (result.elapsedMs / 1000).toFixed(1);
41
+ const degraded = result.degraded
42
+ ? " (degraded: synthesis unavailable)"
43
+ : "";
44
+ process.stderr.write(`\n(${result.steps} steps, ${seconds}s)${degraded}\n`);
45
+ });
46
+ }
47
+ }
48
+ //# sourceMappingURL=AskCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AskCommand.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/AskCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO1C;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACO;IAA7B,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,QAAQ,CAAC,OAAgB;QACxB,UAAU,CAAC,MAAM,CAChB,OAAO;aACL,OAAO,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BAChC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;gBACnE,CAAC;YACF,CAAC;YAED,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ;gBAC/B,CAAC,CAAC,oCAAoC;gBACtC,CAAC,CAAC,EAAE,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,KAAK,CACnB,MAAM,MAAM,CAAC,KAAK,WAAW,OAAO,KAAK,QAAQ,IAAI,CACrD,CAAC;QACH,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
@@ -0,0 +1,18 @@
1
+ import type { Command } from "commander";
2
+ import type { CommandContext } from "../CommandContext.js";
3
+ /** `lmgrep completions` — shell completion scripts. */
4
+ export declare class CompletionsCommand {
5
+ private readonly context;
6
+ /** Preferred first: a user-local path needs no privileges. */
7
+ private static readonly ZSH_CANDIDATES;
8
+ constructor(context: CommandContext);
9
+ register(program: Command): void;
10
+ private runZsh;
11
+ /**
12
+ * The first candidate directory that exists and is writable, or that we can
13
+ * create. `$fpath` is consulted too, since a user's zsh setup may put
14
+ * site-functions somewhere unusual.
15
+ */
16
+ private findSiteFunctions;
17
+ private fpathEntries;
18
+ }
@@ -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,GAAG;QACxC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,CAAC;QAC3D,qCAAqC;QACrC,+BAA+B;KAC/B,CAAC;IAEF,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,QAAQ,CAAC,OAAgB;QACxB,MAAM,WAAW,GAAG,OAAO;aACzB,OAAO,CAAC,aAAa,CAAC;aACtB,WAAW,CAAC,0BAA0B,CAAC,CAAC;QAE1C,WAAW;aACT,OAAO,CAAC,KAAK,CAAC;aACd,WAAW,CAAC,wBAAwB,CAAC;aACrC,MAAM,CAAC,WAAW,EAAE,kDAAkD,CAAC;aACvE,MAAM,CAAC,CAAC,OAA8B,EAAE,EAAE,CAAC,IAAI,CAAC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QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;QACF,CAAC;QAED,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACpC,IAAI,CAAC;gBACJ,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC3B,wDAAwD;oBACxD,cAAc;oBACd,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;oBAC9C,aAAa,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBACzB,MAAM,CAAC,KAAK,CAAC,CAAC;oBACd,OAAO,SAAS,CAAC;gBAClB,CAAC;gBACD,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;oBACvC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC1C,OAAO,SAAS,CAAC;gBAClB,CAAC;YACF,CAAC;YAAC,MAAM,CAAC;gBACR,yCAAyC;YAC1C,CAAC;QACF,CAAC;QACD,OAAO,SAAS,CAAC;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,56 @@
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 preview;
54
+ private write;
55
+ private registerConfig;
56
+ }