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,63 @@
1
+ import { DockerModelRunnerProbe } from "./DockerModelRunnerProbe.js";
2
+ import { LmStudioProbe } from "./LmStudioProbe.js";
3
+ import { OllamaProbe } from "./OllamaProbe.js";
4
+ /**
5
+ * Finds whichever local inference server is running.
6
+ *
7
+ * Probes run concurrently and the first *useful* result wins — a server with
8
+ * models beats one that is merely listening, so a running-but-empty Ollama
9
+ * does not shadow a fully set up LM Studio.
10
+ */
11
+ export class LocalRuntimeDetector {
12
+ probes;
13
+ constructor(probes = [
14
+ new DockerModelRunnerProbe(),
15
+ new LmStudioProbe(),
16
+ new OllamaProbe(),
17
+ ]) {
18
+ this.probes = probes;
19
+ }
20
+ async detectAll() {
21
+ const results = await Promise.all(this.probes.map((p) => p.detect().catch(() => undefined)));
22
+ return results.filter((r) => r !== undefined);
23
+ }
24
+ /** The best runtime to configure against, if any is usable. */
25
+ async detectBest() {
26
+ const found = await this.detectAll();
27
+ return (found.find((r) => LocalRuntimeDetector.embeddingModels(r).length > 0) ??
28
+ found[0]);
29
+ }
30
+ /**
31
+ * Models the runtime says are embedders, best candidate first.
32
+ *
33
+ * A loaded model sorts ahead of the rest. Runtimes list models in an order
34
+ * of their own — LM Studio appears to use recency — and picking by position
35
+ * means the choice silently changes depending on what was used last.
36
+ * Load state is an explicit signal instead of an incidental one.
37
+ */
38
+ static embeddingModels(runtime) {
39
+ return LocalRuntimeDetector.loadedFirst(runtime.models.filter((m) => m.kind === "embedding"));
40
+ }
41
+ /** Stable sort putting loaded models first, order otherwise preserved. */
42
+ static loadedFirst(models) {
43
+ return [
44
+ ...models.filter((m) => m.loaded),
45
+ ...models.filter((m) => !m.loaded),
46
+ ];
47
+ }
48
+ /**
49
+ * Models usable for `ask`. Only taken when the runtime typed them: guessing
50
+ * an embedder is a chat model produces a confusing failure at answer time.
51
+ */
52
+ static chatModels(runtime) {
53
+ return LocalRuntimeDetector.loadedFirst(runtime.models.filter((m) => m.kind === "chat"));
54
+ }
55
+ /**
56
+ * Fallback for runtimes that do not type their models: anything not
57
+ * recognizable as an embedder.
58
+ */
59
+ static untypedModels(runtime) {
60
+ return LocalRuntimeDetector.loadedFirst(runtime.models.filter((m) => m.kind === "unknown"));
61
+ }
62
+ }
63
+ //# sourceMappingURL=LocalRuntimeDetector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalRuntimeDetector.js","sourceRoot":"","sources":["../../../src/infrastructure/ai/LocalRuntimeDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IAEd;IADlB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AAC;SAClC,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,OAAwB;QACzC,OAAO,oBAAoB,CAAC,WAAW,CACtC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAC/C,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,OAAwB;QAC5C,OAAO,oBAAoB,CAAC,WAAW,CACtC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAClD,CAAC;IACH,CAAC;CACD"}
@@ -0,0 +1,32 @@
1
+ /** What a discovered model is good for. */
2
+ export type ModelKind = "embedding" | "chat" | "unknown";
3
+ export interface CatalogedModel {
4
+ id: string;
5
+ kind: ModelKind;
6
+ /**
7
+ * Currently loaded in the runtime.
8
+ *
9
+ * The strongest statement of intent available without asking: a model the
10
+ * user has deliberately loaded is the one they mean. Undefined when the
11
+ * runtime does not report load state.
12
+ */
13
+ loaded?: boolean;
14
+ }
15
+ /** A local inference server that was found listening. */
16
+ export interface DetectedRuntime {
17
+ /** Human name, for what `init` prints. */
18
+ label: string;
19
+ /** Provider segment of the `provider:model` string. */
20
+ providerId: string;
21
+ baseURL: string;
22
+ /**
23
+ * AI SDK package to load. Undefined means the default
24
+ * `@ai-sdk/<providerId>` is correct.
25
+ */
26
+ providerPackage?: string;
27
+ models: CatalogedModel[];
28
+ }
29
+ /** Detects one kind of local inference server. */
30
+ export interface RuntimeProbe {
31
+ detect(): Promise<DetectedRuntime | undefined>;
32
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ModelRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelRuntime.js","sourceRoot":"","sources":["../../../src/infrastructure/ai/ModelRuntime.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import type { DetectedRuntime, RuntimeProbe } from "./ModelRuntime.js";
2
+ /**
3
+ * Detects a local Ollama server.
4
+ *
5
+ * Ollama's tag listing does not say what a model is for, so kind is inferred
6
+ * from the name. That is a guess, and marked as one — `unknown` models are
7
+ * offered only when nothing better is found.
8
+ */
9
+ export declare class OllamaProbe implements RuntimeProbe {
10
+ private static readonly TAGS_URL;
11
+ /** Models currently resident in memory. */
12
+ private static readonly RUNNING_URL;
13
+ static readonly BASE_URL = "http://localhost:11434/v1";
14
+ static readonly PROVIDER_PACKAGE = "@ai-sdk/openai-compatible";
15
+ private static readonly TIMEOUT_MS;
16
+ /** Name fragments that reliably indicate an embedding model. */
17
+ private static readonly EMBEDDING_HINTS;
18
+ detect(): Promise<DetectedRuntime | undefined>;
19
+ /** Best-effort; an older Ollama without this endpoint just reports none. */
20
+ private loadedModelNames;
21
+ private static looksLikeEmbedding;
22
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Detects a local Ollama server.
3
+ *
4
+ * Ollama's tag listing does not say what a model is for, so kind is inferred
5
+ * from the name. That is a guess, and marked as one — `unknown` models are
6
+ * offered only when nothing better is found.
7
+ */
8
+ export class OllamaProbe {
9
+ static TAGS_URL = "http://localhost:11434/api/tags";
10
+ /** Models currently resident in memory. */
11
+ static RUNNING_URL = "http://localhost:11434/api/ps";
12
+ static BASE_URL = "http://localhost:11434/v1";
13
+ static PROVIDER_PACKAGE = "@ai-sdk/openai-compatible";
14
+ static TIMEOUT_MS = 3000;
15
+ /** Name fragments that reliably indicate an embedding model. */
16
+ static EMBEDDING_HINTS = [
17
+ "embed",
18
+ "nomic",
19
+ "bge",
20
+ "minilm",
21
+ "gte-",
22
+ "e5-",
23
+ ];
24
+ async detect() {
25
+ let payload;
26
+ try {
27
+ const res = await fetch(OllamaProbe.TAGS_URL, {
28
+ signal: AbortSignal.timeout(OllamaProbe.TIMEOUT_MS),
29
+ });
30
+ if (!res.ok)
31
+ return undefined;
32
+ payload = (await res.json());
33
+ }
34
+ catch {
35
+ return undefined;
36
+ }
37
+ const loaded = await this.loadedModelNames();
38
+ const models = (payload.models ?? []).map((m) => ({
39
+ id: m.name,
40
+ kind: OllamaProbe.looksLikeEmbedding(m.name) ? "embedding" : "unknown",
41
+ loaded: loaded.has(m.name),
42
+ }));
43
+ return {
44
+ label: "Ollama",
45
+ providerId: "ollama",
46
+ baseURL: OllamaProbe.BASE_URL,
47
+ providerPackage: OllamaProbe.PROVIDER_PACKAGE,
48
+ models,
49
+ };
50
+ }
51
+ /** Best-effort; an older Ollama without this endpoint just reports none. */
52
+ async loadedModelNames() {
53
+ try {
54
+ const res = await fetch(OllamaProbe.RUNNING_URL, {
55
+ signal: AbortSignal.timeout(OllamaProbe.TIMEOUT_MS),
56
+ });
57
+ if (!res.ok)
58
+ return new Set();
59
+ const payload = (await res.json());
60
+ return new Set((payload.models ?? []).map((m) => m.name));
61
+ }
62
+ catch {
63
+ return new Set();
64
+ }
65
+ }
66
+ static looksLikeEmbedding(name) {
67
+ const lower = name.toLowerCase();
68
+ return OllamaProbe.EMBEDDING_HINTS.some((hint) => lower.includes(hint));
69
+ }
70
+ }
71
+ //# sourceMappingURL=OllamaProbe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OllamaProbe.js","sourceRoot":"","sources":["../../../src/infrastructure/ai/OllamaProbe.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,MAAM,OAAO,WAAW;IACf,MAAM,CAAU,QAAQ,GAAG,iCAAiC,CAAC;IACrE,2CAA2C;IACnC,MAAM,CAAU,WAAW,GAAG,+BAA+B,CAAC;IACtE,MAAM,CAAU,QAAQ,GAAG,2BAA2B,CAAC;IACvD,MAAM,CAAU,gBAAgB,GAAG,2BAA2B,CAAC;IACvD,MAAM,CAAU,UAAU,GAAG,IAAI,CAAC;IAE1C,gEAAgE;IACxD,MAAM,CAAU,eAAe,GAAG;QACzC,OAAO;QACP,OAAO;QACP,KAAK;QACL,Q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,UAAU,CAAC;aACnD,CAAC,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,EAAE;gBAAE,OAAO,IAAI,GAAG,EAAE,CAAC;YAC9B,MAAM,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAEhC,CAAC;YACF,OAAO,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3D,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,IAAI,GAAG,EAAE,CAAC;QAClB,CAAC;IACF,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAAC,IAAY;QAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACjC,OAAO,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACzE,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Classifies provider errors that the research loop must handle differently
3
+ * from a genuine failure.
4
+ *
5
+ * A timeout and a context overflow both mean "the loop cannot continue, but
6
+ * what it gathered is still good" — they fall through to synthesis rather than
7
+ * degrading the whole run.
8
+ */
9
+ export declare class ProviderFailure {
10
+ private static readonly OVERFLOW_PATTERN;
11
+ static isAbort(error: unknown): boolean;
12
+ /** A provider 400 whose body mentions the context window being exceeded. */
13
+ static isContextOverflow(error: unknown): boolean;
14
+ /** Opt-in diagnostics; provider errors carry detail worth seeing. */
15
+ static debug(where: string, error: unknown): void;
16
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Classifies provider errors that the research loop must handle differently
3
+ * from a genuine failure.
4
+ *
5
+ * A timeout and a context overflow both mean "the loop cannot continue, but
6
+ * what it gathered is still good" — they fall through to synthesis rather than
7
+ * degrading the whole run.
8
+ */
9
+ export class ProviderFailure {
10
+ static OVERFLOW_PATTERN = /context (size|length|window)|exceed|too (long|large)|max.*token/i;
11
+ static isAbort(error) {
12
+ return (error instanceof Error &&
13
+ (error.name === "AbortError" || error.name === "TimeoutError"));
14
+ }
15
+ /** A provider 400 whose body mentions the context window being exceeded. */
16
+ static isContextOverflow(error) {
17
+ const e = error;
18
+ if (e?.statusCode !== 400)
19
+ return false;
20
+ return ProviderFailure.OVERFLOW_PATTERN.test(`${e.responseBody ?? ""} ${e.message ?? ""}`);
21
+ }
22
+ /** Opt-in diagnostics; provider errors carry detail worth seeing. */
23
+ static debug(where, error) {
24
+ if (!process.env.LMGREP_DEBUG)
25
+ return;
26
+ const e = error;
27
+ console.error(`[lmgrep debug] ${where} error:`, {
28
+ name: e?.name,
29
+ message: e?.message,
30
+ statusCode: e?.statusCode,
31
+ responseBody: e?.responseBody,
32
+ });
33
+ }
34
+ }
35
+ //# sourceMappingURL=ProviderFailure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderFailure.js","sourceRoot":"","sources":["../../../src/infrastructure/ai/ProviderFailure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IACnB,MAAM,CAAU,gBAAgB,GACvC,kEAAkE,CAAC;IAEpE,MAAM,CAAC,OAAO,CAAC,KAAc;QAC5B,OAAO,CACN,KAAK,YAAY,KAAK;YACtB,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,CAC9D,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,MAAM,CAAC,iBAAiB,CAAC,KAAc;QACtC,MAAM,CAAC,GAAG,KAIT,CAAC;QACF,IAAI,CAAC,EAAE,UAAU,KAAK,GAAG;YAAE,OAAO,KAAK,CAAC;QACxC,OAAO,eAAe,CAAC,gBAAgB,CAAC,IAAI,CAC3C,GAAG,CAAC,CAAC,YAAY,IAAI,EAAE,IAAI,CAAC,CAAC,OAAO,IAAI,EAAE,EAAE,CAC5C,CAAC;IACH,CAAC;IAED,qEAAqE;IACrE,MAAM,CAAC,KAAK,CAAC,KAAa,EAAE,KAAc;QACzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY;YAAE,OAAO;QACtC,MAAM,CAAC,GAAG,KAAgC,CAAC;QAC3C,OAAO,CAAC,KAAK,CAAC,kBAAkB,KAAK,SAAS,EAAE;YAC/C,IAAI,EAAE,CAAC,EAAE,IAAI;YACb,OAAO,EAAE,CAAC,EAAE,OAAO;YACnB,UAAU,EAAE,CAAC,EAAE,UAAU;YACzB,YAAY,EAAE,CAAC,EAAE,YAAY;SAC7B,CAAC,CAAC;IACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Imports an AI SDK provider package.
3
+ *
4
+ * The OpenAI-compatible adapter is statically bundled so local runtimes work
5
+ * in the standalone executable. Other providers remain plugins: resolution
6
+ * reaches beyond this package's own `node_modules`, allowing a global install.
7
+ */
8
+ export declare class ProviderModuleLoader {
9
+ private readonly cache;
10
+ private readonly bundled;
11
+ load(packageName: string): Promise<Record<string, unknown>>;
12
+ private resolve;
13
+ private globalModulePaths;
14
+ }
@@ -0,0 +1,56 @@
1
+ import { execSync } from "node:child_process";
2
+ import { createRequire } from "node:module";
3
+ import { join } from "node:path";
4
+ import * as openAICompatible from "@ai-sdk/openai-compatible";
5
+ /**
6
+ * Imports an AI SDK provider package.
7
+ *
8
+ * The OpenAI-compatible adapter is statically bundled so local runtimes work
9
+ * in the standalone executable. Other providers remain plugins: resolution
10
+ * reaches beyond this package's own `node_modules`, allowing a global install.
11
+ */
12
+ export class ProviderModuleLoader {
13
+ cache = new Map();
14
+ bundled = new Map([
15
+ ["@ai-sdk/openai-compatible", openAICompatible],
16
+ ]);
17
+ async load(packageName) {
18
+ const bundled = this.bundled.get(packageName);
19
+ if (bundled)
20
+ return bundled;
21
+ const cached = this.cache.get(packageName);
22
+ if (cached)
23
+ return cached;
24
+ const loaded = await this.resolve(packageName);
25
+ this.cache.set(packageName, loaded);
26
+ return loaded;
27
+ }
28
+ async resolve(packageName) {
29
+ // Local resolution first — the common case.
30
+ try {
31
+ return await import(packageName);
32
+ }
33
+ catch { }
34
+ for (const globalPath of this.globalModulePaths()) {
35
+ try {
36
+ const req = createRequire(join(globalPath, ".placeholder"));
37
+ return await import(req.resolve(packageName));
38
+ }
39
+ catch { }
40
+ }
41
+ throw new Error(`Provider "${packageName}" is not installed. Run:\n\n npm install -g ${packageName}\n`);
42
+ }
43
+ globalModulePaths() {
44
+ const paths = [];
45
+ for (const command of ["pnpm root -g", "npm root -g"]) {
46
+ try {
47
+ const out = execSync(command, { stdio: "pipe" }).toString().trim();
48
+ if (out)
49
+ paths.push(out);
50
+ }
51
+ catch { }
52
+ }
53
+ return paths;
54
+ }
55
+ }
56
+ //# sourceMappingURL=ProviderModuleLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderModuleLoader.js","sourceRoot":"","sources":["../../../src/infrastructure/ai/ProviderModuleLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,gBAAgB,MAAM,2BAA2B,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IACf,KAAK,GAAG,IAAI,GAAG,EAAmC,CAAC;IAEnD,OAAO,GAAG,IAAI,GAAG,CAAkC;QACnE,CAAC,2BAA2B,EAAE,gBAAgB,CAAC;KAC/C,CAAC,CAAC;IAEH,KAAK,CAAC,IAAI,CAAC,WAAmB;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC9C,IAAI,OAAO;YAAE,OAAO,OAAO,CAAC;QAE5B,MAAM,MAAM,GAAG,IAAI,CAAC,KA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;IACd,CAAC;CACD"}
@@ -0,0 +1,38 @@
1
+ import { ProviderModuleLoader } from "./ProviderModuleLoader.js";
2
+ /** A `provider:model` string split into its parts. */
3
+ export declare class ModelReference {
4
+ readonly provider: string;
5
+ readonly model: string;
6
+ readonly full: string;
7
+ private constructor();
8
+ static parse(value: string, label: string): ModelReference;
9
+ }
10
+ export interface ProviderRequest {
11
+ reference: ModelReference;
12
+ /** Package to import; defaults to `@ai-sdk/<provider>`. */
13
+ packageName?: string;
14
+ baseURL?: string;
15
+ /**
16
+ * Whether a configured `baseURL` should force use of the `create*` factory
17
+ * even when the module exports a ready-made default instance.
18
+ *
19
+ * It matters because a bare default export (e.g. `openai`) ignores baseURL
20
+ * and would silently talk to the cloud. The chat path sets this; the
21
+ * embedding path historically does not, and the two are kept distinct here
22
+ * rather than quietly unified.
23
+ */
24
+ preferFactoryWhenBaseUrlSet: boolean;
25
+ }
26
+ /**
27
+ * Turns a `provider:model` string plus config into a live AI SDK provider.
28
+ *
29
+ * Both the embedding and chat paths need the same import-and-instantiate
30
+ * dance, so it lives here once; the one place they genuinely differ is
31
+ * expressed as {@link ProviderRequest.preferFactoryWhenBaseUrlSet}.
32
+ */
33
+ export declare class ProviderRegistry {
34
+ private readonly loader;
35
+ private static readonly OPENAI_COMPATIBLE_PROVIDERS;
36
+ constructor(loader?: ProviderModuleLoader);
37
+ instantiate(request: ProviderRequest): Promise<unknown>;
38
+ }
@@ -0,0 +1,63 @@
1
+ import { ProviderModuleLoader } from "./ProviderModuleLoader.js";
2
+ /** A `provider:model` string split into its parts. */
3
+ export class ModelReference {
4
+ provider;
5
+ model;
6
+ full;
7
+ constructor(provider, model, full) {
8
+ this.provider = provider;
9
+ this.model = model;
10
+ this.full = full;
11
+ }
12
+ static parse(value, label) {
13
+ const colon = value.indexOf(":");
14
+ if (colon === -1) {
15
+ throw new Error(`${label} must be in "provider:model" format. Got: "${value}"`);
16
+ }
17
+ return new ModelReference(value.slice(0, colon), value.slice(colon + 1), value);
18
+ }
19
+ }
20
+ /**
21
+ * Turns a `provider:model` string plus config into a live AI SDK provider.
22
+ *
23
+ * Both the embedding and chat paths need the same import-and-instantiate
24
+ * dance, so it lives here once; the one place they genuinely differ is
25
+ * expressed as {@link ProviderRequest.preferFactoryWhenBaseUrlSet}.
26
+ */
27
+ export class ProviderRegistry {
28
+ loader;
29
+ static OPENAI_COMPATIBLE_PROVIDERS = new Set([
30
+ "docker",
31
+ "lmstudio",
32
+ "ollama",
33
+ ]);
34
+ constructor(loader = new ProviderModuleLoader()) {
35
+ this.loader = loader;
36
+ }
37
+ async instantiate(request) {
38
+ const providerName = request.reference.provider;
39
+ const packageName = request.packageName ??
40
+ (ProviderRegistry.OPENAI_COMPATIBLE_PROVIDERS.has(providerName)
41
+ ? "@ai-sdk/openai-compatible"
42
+ : `@ai-sdk/${providerName}`);
43
+ const module = await this.loader.load(packageName);
44
+ let instance = module[providerName];
45
+ const forceFactory = request.preferFactoryWhenBaseUrlSet && Boolean(request.baseURL);
46
+ if (!instance || forceFactory) {
47
+ const factoryKey = Object.keys(module).find((k) => k.startsWith("create"));
48
+ if (factoryKey) {
49
+ const factory = module[factoryKey];
50
+ instance = factory({
51
+ name: providerName,
52
+ ...(request.baseURL ? { baseURL: request.baseURL } : {}),
53
+ });
54
+ }
55
+ }
56
+ if (!instance) {
57
+ throw new Error(`Package "${packageName}" has no usable provider export. ` +
58
+ `Available: ${Object.keys(module).join(", ")}`);
59
+ }
60
+ return instance;
61
+ }
62
+ }
63
+ //# sourceMappingURL=ProviderRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderRegistry.js","sourceRoot":"","sources":["../../../src/infrastructure/ai/ProviderRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,sDAAsD;AACtD,MAAM,OAAO,cAAc;IAEhB;IACA;IACA;IAHV,YACU,QAAgB,EAChB,KAAa,EACb,IAAY;QAFZ,aAAQ,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,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC,QAAQ,IAAI,YAAY,EAAE,CAAC;YAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CACjD,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CACtB,CAAC;YACF,IAAI,UAAU,EAAE,CAAC;gBAChB,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAErB,CAAC;gBACb,QAAQ,GAAG,OAAO,CAAC;oBAClB,IAAI,EAAE,YAAY;oBAClB,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACxD,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACd,YAAY,WAAW,mCAAmC;gBACzD,cAAc,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC/C,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC;IACjB,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { ConfigSource } from "../../domain/config/ConfigSource.js";
2
+ import type { LmgrepConfig } from "../../domain/config/LmgrepConfig.js";
3
+ /**
4
+ * Loads configuration from two kinds of file, split by what the settings
5
+ * actually describe.
6
+ *
7
+ * **Machine settings** — which model to embed with, which to answer with,
8
+ * where those servers listen — describe *this computer's* inference setup.
9
+ * They live in one global file. They used to be settable per project too,
10
+ * which was the single most confusing thing about lmgrep: the model determines
11
+ * what a stored vector *means*, so a project file could silently point an
12
+ * index at incompatible embeddings, and `status` would report an effective
13
+ * model without saying which of three files produced it.
14
+ *
15
+ * **Project settings** — what to ignore, which extensions to index — describe
16
+ * *this repository*, are worth committing, and mean the same thing on every
17
+ * machine that checks it out.
18
+ *
19
+ * Machine keys found in a project file are reported and ignored rather than
20
+ * applied. Wanting a different model for one project is a real thing to want;
21
+ * it is now spelled as a different database (`--database`), because the model
22
+ * is a property of an index rather than of a directory.
23
+ */
24
+ export declare class ConfigLoader {
25
+ /** Settings that describe this machine's inference setup. */
26
+ private static readonly MACHINE_SCHEMA;
27
+ /** Settings that describe a repository. */
28
+ private static readonly PROJECT_SCHEMA;
29
+ private static readonly FILE_NAME;
30
+ private static readonly PROJECT_FILE_NAMES;
31
+ private static readonly DEFAULTS;
32
+ /** Populated by {@link load}: what was read, and what was ignored. */
33
+ readonly sources: ConfigSource[];
34
+ readonly warnings: string[];
35
+ load(cwd: string): LmgrepConfig;
36
+ /**
37
+ * The XDG-compliant global config directory.
38
+ * Linux: $XDG_CONFIG_HOME/lmgrep or ~/.config/lmgrep
39
+ * macOS: ~/Library/Application Support/lmgrep
40
+ */
41
+ configDirectory(): string;
42
+ globalConfigPath(): string;
43
+ /** Path of the project file in `cwd`, whether or not it exists. */
44
+ projectConfigPath(cwd: string): string;
45
+ /**
46
+ * Parse a single machine config file, ignoring the layering.
47
+ *
48
+ * `init` rewrites one specific file, so it needs that file's own contents —
49
+ * merging layers here would copy one file's settings into another.
50
+ */
51
+ readFile(path: string): Partial<LmgrepConfig> | undefined;
52
+ private readMachineFile;
53
+ private readProjectFile;
54
+ private parseYaml;
55
+ private pick;
56
+ private static machineKeys;
57
+ private static projectKeys;
58
+ private validate;
59
+ }