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,96 @@
1
+ /**
2
+ * An embedding as a value object: a chunk's meaning, or a query's, as a point
3
+ * in the model's vector space.
4
+ *
5
+ * Every operation returns a new Vector; none mutate. Raw `number[]` stays the
6
+ * wire format at the LanceDB and provider boundaries — this type is for the
7
+ * domain, where naming the operation matters more than avoiding an allocation.
8
+ *
9
+ * Keep it that way. Scoring a whole table happens inside LanceDB, natively;
10
+ * the operations here run over single queries and result pages, where the
11
+ * allocations are free.
12
+ */
13
+ export class Vector {
14
+ values;
15
+ constructor(values) {
16
+ this.values = values;
17
+ }
18
+ static from(values) {
19
+ return new Vector(values instanceof Float32Array ? Array.from(values) : values);
20
+ }
21
+ /** Zero vector of the given width — the identity for {@link plus}. */
22
+ static zeros(dimensions) {
23
+ return new Vector(new Array(dimensions).fill(0));
24
+ }
25
+ static mean(vectors) {
26
+ if (vectors.length === 0) {
27
+ throw new Error("Cannot take the mean of zero vectors");
28
+ }
29
+ return Vector.sum(vectors).scaledBy(1 / vectors.length);
30
+ }
31
+ static sum(vectors) {
32
+ if (vectors.length === 0) {
33
+ throw new Error("Cannot sum zero vectors");
34
+ }
35
+ const out = new Array(vectors[0].values.length).fill(0);
36
+ for (const v of vectors) {
37
+ for (let i = 0; i < out.length; i++)
38
+ out[i] += v.values[i];
39
+ }
40
+ return new Vector(out);
41
+ }
42
+ get dimensions() {
43
+ return this.values.length;
44
+ }
45
+ /** A mutable copy, for the provider and LanceDB boundaries. */
46
+ toArray() {
47
+ return [...this.values];
48
+ }
49
+ componentAt(index) {
50
+ return this.values[index];
51
+ }
52
+ dot(other) {
53
+ let s = 0;
54
+ for (let i = 0; i < this.values.length; i++) {
55
+ s += this.values[i] * other.values[i];
56
+ }
57
+ return s;
58
+ }
59
+ plus(other) {
60
+ const out = new Array(this.values.length);
61
+ for (let i = 0; i < out.length; i++) {
62
+ out[i] = this.values[i] + other.values[i];
63
+ }
64
+ return new Vector(out);
65
+ }
66
+ minus(other) {
67
+ const out = new Array(this.values.length);
68
+ for (let i = 0; i < out.length; i++) {
69
+ out[i] = this.values[i] - other.values[i];
70
+ }
71
+ return new Vector(out);
72
+ }
73
+ scaledBy(factor) {
74
+ const out = new Array(this.values.length);
75
+ for (let i = 0; i < out.length; i++)
76
+ out[i] = this.values[i] * factor;
77
+ return new Vector(out);
78
+ }
79
+ /** Unit vector in the same direction. A zero vector is returned unchanged. */
80
+ normalized() {
81
+ let s = 0;
82
+ for (const v of this.values)
83
+ s += v * v;
84
+ const n = Math.sqrt(s) || 1;
85
+ return this.scaledBy(1 / n);
86
+ }
87
+ /**
88
+ * Cosine distance, valid only for unit vectors — callers normalize first.
89
+ * Kept as `1 - dot` rather than a general cosine so the clustering hot path
90
+ * does not re-derive magnitudes it already knows are 1.
91
+ */
92
+ cosineDistanceTo(other) {
93
+ return 1 - this.dot(other);
94
+ }
95
+ }
96
+ //# sourceMappingURL=Vector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Vector.js","sourceRoot":"","sources":["../../../src/domain/corpus/Vector.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,57 @@
1
+ /** A search the model asked for during a research loop. */
2
+ export interface SearchToolCall {
3
+ query: string;
4
+ filePrefix?: string;
5
+ type?: string[];
6
+ language?: string[];
7
+ limit?: number;
8
+ }
9
+ /**
10
+ * How a model run ended.
11
+ *
12
+ * `interrupted` is separated from `failed` on purpose: a step cap, a timeout,
13
+ * or an overflowed context all leave the evidence gathered so far intact and
14
+ * worth synthesizing from, whereas a failure means the model is unreachable.
15
+ */
16
+ export type ChatOutcome = {
17
+ status: "completed";
18
+ text: string;
19
+ steps: number;
20
+ } | {
21
+ status: "interrupted";
22
+ reason: "timeout" | "context-overflow";
23
+ steps: number;
24
+ } | {
25
+ status: "failed";
26
+ error: unknown;
27
+ steps: number;
28
+ };
29
+ export interface ToolLoopRequest {
30
+ system: string;
31
+ prompt: string;
32
+ maxSteps: number;
33
+ timeoutMs: number;
34
+ /** Describes the search tool to the model. */
35
+ toolDescription: string;
36
+ /** Runs a search the model requested, returning the text it should see. */
37
+ onSearch: (call: SearchToolCall) => Promise<string>;
38
+ }
39
+ export interface CompletionRequest {
40
+ system: string;
41
+ prompt: string;
42
+ timeoutMs: number;
43
+ }
44
+ /**
45
+ * A generative model that can drive a search tool.
46
+ *
47
+ * Deliberately narrow: research needs exactly one agentic loop and one
48
+ * single-shot completion, and keeping the port that small is what stops the
49
+ * provider SDK leaking into the use case.
50
+ */
51
+ export interface ChatModelPort {
52
+ /** Whether a model is configured at all — `ask` is hidden when not. */
53
+ readonly isConfigured: boolean;
54
+ runToolLoop(request: ToolLoopRequest): Promise<ChatOutcome>;
55
+ /** One-shot completion; undefined when the model produced nothing. */
56
+ complete(request: CompletionRequest): Promise<string | undefined>;
57
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ChatModelPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatModelPort.js","sourceRoot":"","sources":["../../../src/domain/ports/ChatModelPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ import type { Chunk } from "../corpus/Chunk.js";
2
+ import type { ContentHash } from "../corpus/ContentHash.js";
3
+ import type { Vector } from "../corpus/Vector.js";
4
+ import type { HitList } from "../retrieval/HitList.js";
5
+ /** A chunk paired with the embedding to store alongside it. */
6
+ export interface EmbeddedChunk {
7
+ chunk: Chunk;
8
+ vector: Vector;
9
+ }
10
+ /** The filters pushed down into the vector query rather than applied after. */
11
+ export interface ChunkQuery {
12
+ vector: Vector;
13
+ limit: number;
14
+ /** Restrict to files under this repo-relative prefix. */
15
+ filePrefix?: string;
16
+ /** Restrict to these AST node types. */
17
+ types?: string[];
18
+ /**
19
+ * Whether to restrict results to the file versions the current branch
20
+ * references. Off for cross-project search, where the foreign database has
21
+ * no manifest for our branch.
22
+ */
23
+ scopeToBranch: boolean;
24
+ }
25
+ /** Text of one chunk, for vocabulary building. */
26
+ export interface ChunkText {
27
+ name: string;
28
+ content: string;
29
+ }
30
+ /** Persistence for embedded chunks. */
31
+ export interface ChunkRepositoryPort {
32
+ add(chunks: EmbeddedChunk[]): Promise<void>;
33
+ search(query: ChunkQuery): Promise<HitList>;
34
+ deleteByFiles(filePaths: string[]): Promise<void>;
35
+ /** Of the given chunk hashes, those already stored. */
36
+ existingHashes(hashes: ContentHash[]): Promise<Set<string>>;
37
+ count(): Promise<number>;
38
+ /** Chunk hashes grouped by file path, for status reporting. */
39
+ hashesByFile(): Promise<Map<string, string[]>>;
40
+ allHashes(): Promise<Set<string>>;
41
+ streamTexts(batchSize?: number): AsyncGenerator<ChunkText[]>;
42
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ChunkRepositoryPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChunkRepositoryPort.js","sourceRoot":"","sources":["../../../src/domain/ports/ChunkRepositoryPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { Chunk } from "../corpus/Chunk.js";
2
+ /** Splits a source file into indexable chunks. */
3
+ export interface ChunkerPort {
4
+ chunk(filePath: string, cwd: string): Promise<Chunk[]>;
5
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ChunkerPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChunkerPort.js","sourceRoot":"","sources":["../../../src/domain/ports/ChunkerPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The lifecycle of an open database connection.
3
+ *
4
+ * Closing matters: a LanceDB connection holds a native runtime and its decode
5
+ * buffers, so a CLI process that forgets to close one keeps that memory until
6
+ * it exits.
7
+ */
8
+ export interface DatabaseSessionPort {
9
+ close(): void;
10
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=DatabaseSessionPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseSessionPort.js","sourceRoot":"","sources":["../../../src/domain/ports/DatabaseSessionPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { Vector } from "../corpus/Vector.js";
2
+ /**
3
+ * Turns text into embeddings.
4
+ *
5
+ * Documents and queries are separate operations because several models want
6
+ * different prefixes for each ("search_document: " vs "search_query: "), and
7
+ * getting that wrong degrades retrieval silently.
8
+ */
9
+ export interface EmbedderPort {
10
+ /** Embed indexable documents, in provider-sized batches. */
11
+ embedDocuments(texts: string[]): Promise<Vector[]>;
12
+ /** Embed a single search query. */
13
+ embedQuery(query: string): Promise<Vector>;
14
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=EmbedderPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmbedderPort.js","sourceRoot":"","sources":["../../../src/domain/ports/EmbedderPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ import type { ContentHash } from "../corpus/ContentHash.js";
2
+ import type { FileManifest, SourceFile } from "../corpus/SourceFile.js";
3
+ import type { Branch } from "../project/Branch.js";
4
+ /** One manifest row: a file version recorded on a branch. */
5
+ export interface ManifestEntry {
6
+ filePath: string;
7
+ fileHash: ContentHash;
8
+ branch: Branch;
9
+ }
10
+ /**
11
+ * The branch-scoped record of which file versions are indexed.
12
+ *
13
+ * Chunks are shared across branches by content; this is what decides which of
14
+ * them a branch can see.
15
+ */
16
+ export interface FileManifestRepositoryPort {
17
+ /** Manifest for the repository's own branch. */
18
+ current(): Promise<FileManifest>;
19
+ /** Cached manifest used for scoping searches; see {@link invalidate}. */
20
+ branchVersions(): Promise<FileManifest | undefined>;
21
+ /** Drop the cached manifest after an index or import. */
22
+ invalidate(): void;
23
+ upsert(entries: SourceFile[]): Promise<void>;
24
+ deleteFiles(filePaths: string[]): Promise<void>;
25
+ /** Of the given file hashes, those any branch has already indexed. */
26
+ knownHashes(hashes: ContentHash[]): Promise<Set<string>>;
27
+ allEntries(): Promise<ManifestEntry[]>;
28
+ storedBranches(): Promise<string[]>;
29
+ deleteBranch(branch: string): Promise<void>;
30
+ /** Copy another branch's manifest onto ours; returns rows copied. */
31
+ copyFromBranch(sourceBranch: string): Promise<number>;
32
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FileManifestRepositoryPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileManifestRepositoryPort.js","sourceRoot":"","sources":["../../../src/domain/ports/FileManifestRepositoryPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The git facts the domain needs. Narrow on purpose: project identity and
3
+ * branch topology only, so the domain never learns that git is a subprocess.
4
+ */
5
+ export interface GitPort {
6
+ /** Absolute path of the working tree root, or undefined outside a repo. */
7
+ toplevel(cwd: string): string | undefined;
8
+ /**
9
+ * Absolute path of the repository directory shared by every worktree —
10
+ * the main checkout's `.git`, even when called from a linked worktree.
11
+ * This is what lets worktrees agree on one index without a registry.
12
+ */
13
+ commonDir(cwd: string): string | undefined;
14
+ /** Current branch name, or "HEAD" when detached. */
15
+ currentBranch(repoRoot: string): string | undefined;
16
+ /** URL of the `origin` remote, if one is configured. */
17
+ originUrl(repoRoot: string): string | undefined;
18
+ /** Merge base of `HEAD` and `ref`, if both are reachable. */
19
+ mergeBase(repoRoot: string, ref: string): string | undefined;
20
+ /** Number of commits `to` is ahead of `from`. */
21
+ commitDistance(repoRoot: string, from: string, to: string): number | undefined;
22
+ /** Local branch names. */
23
+ localBranches(repoRoot: string): string[];
24
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GitPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitPort.js","sourceRoot":"","sources":["../../../src/domain/ports/GitPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,58 @@
1
+ /** What a maintenance pass did to one table. */
2
+ export interface TableOptimizeReport {
3
+ table: string;
4
+ rows: number;
5
+ /**
6
+ * `skipped-small` - below the ANN threshold, flat scan is fine.
7
+ * `needs-index` - big enough to want an index, but training was not
8
+ * requested on this path. Searches stay on flat scan
9
+ * until `lmgrep index` or `lmgrep compact` runs.
10
+ * `created` - trained a vector index for the first time.
11
+ * `optimized` - compacted and absorbed the unindexed tail.
12
+ * `up-to-date` - tail still within tolerance, nothing done.
13
+ * `dropped` - a table no longer part of the schema was removed.
14
+ */
15
+ action: "skipped-small" | "needs-index" | "created" | "optimized" | "up-to-date" | "dropped";
16
+ unindexed?: number;
17
+ }
18
+ export interface OptimizeReport {
19
+ tables: TableOptimizeReport[];
20
+ }
21
+ export interface DedupeReport {
22
+ before: number;
23
+ after: number;
24
+ duplicateIds: number;
25
+ staleVersions: number;
26
+ }
27
+ export interface OptimizeOptions {
28
+ /** Ignore the unindexed-tail tolerance and optimize regardless. */
29
+ force?: boolean;
30
+ /**
31
+ * Permit training an index where none exists. Off by default: training
32
+ * reads every vector and peaks at several GB, which must not happen behind
33
+ * a background watcher.
34
+ */
35
+ create?: boolean;
36
+ }
37
+ /** Whether searches are answered by a vector index or a brute-force scan. */
38
+ export interface VectorIndexState {
39
+ rows: number;
40
+ /** True when a vector index exists for the chunk table. */
41
+ built: boolean;
42
+ /** Rows appended since the index was last refreshed; these are scanned. */
43
+ unindexed: number;
44
+ /** False when the table is too small for an index to be worth training. */
45
+ worthBuilding: boolean;
46
+ }
47
+ /** Index upkeep: compaction, ANN index training, and duplicate removal. */
48
+ export interface IndexMaintenancePort {
49
+ optimize(options?: OptimizeOptions): Promise<OptimizeReport>;
50
+ /** Full unconditional pass, including the non-vector tables. */
51
+ compact(): Promise<OptimizeReport>;
52
+ /** Drop duplicate and stale-version rows, rewriting the table. */
53
+ dedupe(): Promise<DedupeReport>;
54
+ /** Delete every table — a full rebuild from scratch. */
55
+ reset(): Promise<void>;
56
+ /** How searches are currently answered. */
57
+ vectorIndexState(): Promise<VectorIndexState>;
58
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IndexMaintenancePort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndexMaintenancePort.js","sourceRoot":"","sources":["../../../src/domain/ports/IndexMaintenancePort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ import type { IndexMetadata } from "../project/IndexMetadata.js";
2
+ /**
3
+ * Reads and writes the metadata sidecar beside each database.
4
+ *
5
+ * Enumeration is deliberately not here: a database lives inside the repository
6
+ * it describes, so listing them is the registry's job, not the sidecar's.
7
+ */
8
+ export interface IndexMetadataPort {
9
+ read(databasePath: string): IndexMetadata | undefined;
10
+ write(databasePath: string, metadata: Omit<IndexMetadata, "indexedAt">): void;
11
+ /** Whether a directory is an lmgrep database, or safely treatable as one. */
12
+ isDatabaseDirectory(databasePath: string): boolean;
13
+ /**
14
+ * Whether a directory actually holds an index.
15
+ *
16
+ * Deliberately stricter than {@link isDatabaseDirectory}, which answers a
17
+ * different question: that one guards destructive commands and so accepts
18
+ * an empty directory, since deleting one cannot lose data. Listing an
19
+ * empty directory as an index is the opposite mistake — it reports an
20
+ * index that is not there.
21
+ */
22
+ holdsIndex(databasePath: string): boolean;
23
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IndexMetadataPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndexMetadataPort.js","sourceRoot":"","sources":["../../../src/domain/ports/IndexMetadataPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The two locks guarding a database.
3
+ *
4
+ * They are separate because they answer different questions: the maintainer
5
+ * lock says "one process owns watching this index" and lives as long as that
6
+ * process, while the write mutex says "one writer at a time" and is held only
7
+ * around a build. Collapsing them would stop an ad-hoc index from ever running
8
+ * beside a watcher.
9
+ */
10
+ export interface LockPort {
11
+ /** Claim long-lived ownership. False when another live process holds it. */
12
+ acquireMaintainer(): boolean;
13
+ releaseMaintainer(): void;
14
+ isMaintained(): boolean;
15
+ /** Run `work` holding the short-lived write mutex. */
16
+ withWriteLock<T>(work: () => Promise<T>): Promise<T>;
17
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=LockPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LockPort.js","sourceRoot":"","sources":["../../../src/domain/ports/LockPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ /** Where progress and problems are reported. */
2
+ export interface LoggerPort {
3
+ info(message: string): void;
4
+ error(message: string): void;
5
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=LoggerPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoggerPort.js","sourceRoot":"","sources":["../../../src/domain/ports/LoggerPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ /** One model's database for a project. */
2
+ export interface ProjectIndex {
3
+ databasePath: string;
4
+ /** Full model string it was built with, when the sidecar records one. */
5
+ model?: string;
6
+ dimensions?: number;
7
+ indexedAt?: string;
8
+ bytes: number;
9
+ }
10
+ /**
11
+ * The databases a single project holds — one per embedding model.
12
+ *
13
+ * Read by direct observation rather than from bookkeeping: they are siblings
14
+ * in one directory, and looking is both cheaper and more truthful than a
15
+ * registry that can disagree with what is on disk.
16
+ */
17
+ export interface ProjectIndexesPort {
18
+ /** Every database under a project's index home, largest first. */
19
+ list(indexHome: string): ProjectIndex[];
20
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ProjectIndexesPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProjectIndexesPort.js","sourceRoot":"","sources":["../../../src/domain/ports/ProjectIndexesPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ /** A database this machine knows about, and where to find it. */
2
+ export interface RegisteredIndex {
3
+ /** Working tree the index describes. */
4
+ root: string;
5
+ /**
6
+ * Set for a standalone index, named with `--in <name>`.
7
+ *
8
+ * Its `root` is only where it happened to be built from, so it is not a
9
+ * project: cross-project search resolves a project *path* to a database,
10
+ * and following that path would land on a different index entirely.
11
+ */
12
+ name?: string;
13
+ /** Origin remote, when the project has one. */
14
+ remote?: string;
15
+ /** Absolute path of the database directory. */
16
+ databasePath: string;
17
+ /** Full model string the index was built with. */
18
+ model?: string;
19
+ dimensions?: number;
20
+ /** When this entry was last written. */
21
+ indexedAt: string;
22
+ }
23
+ /**
24
+ * The list of indexes on this machine.
25
+ *
26
+ * Databases live inside the repositories they describe, which is what keeps
27
+ * them from being orphaned — but it also means nothing can enumerate them
28
+ * without walking the filesystem. This registry is that list: pointers only,
29
+ * a few hundred bytes each, and never the source of truth. An entry naming a
30
+ * database that no longer exists is a dangling pointer, not lost data, and is
31
+ * detected by looking rather than by bookkeeping.
32
+ */
33
+ export interface ProjectRegistryPort {
34
+ /** Record (or refresh) the entry for a database. */
35
+ record(entry: Omit<RegisteredIndex, "indexedAt">): void;
36
+ /** Entries whose database still exists. */
37
+ list(): RegisteredIndex[];
38
+ /** Entries whose database is gone — safe to forget. */
39
+ dangling(): RegisteredIndex[];
40
+ /** Drop the entry for a database. */
41
+ forget(databasePath: string): void;
42
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ProjectRegistryPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProjectRegistryPort.js","sourceRoot":"","sources":["../../../src/domain/ports/ProjectRegistryPort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Access to the machine-global directory lmgrep keeps beside its databases.
3
+ *
4
+ * Since databases moved inside the repositories they describe, what remains
5
+ * here is only what cannot live in a repository: coordination between
6
+ * processes on this machine, the pointer registry that makes indexes
7
+ * discoverable without scanning the filesystem, and databases for projects
8
+ * that have no repository to live in.
9
+ *
10
+ * Narrow by design: the domain needs to know where state lives, not how to
11
+ * read or write files.
12
+ */
13
+ export interface StateDirectoryPort {
14
+ /** Absolute path of the state root (e.g. ~/.local/state/lmgrep). */
15
+ root(): string;
16
+ /** Whether `path` exists and is a directory. */
17
+ isDirectory(path: string): boolean;
18
+ /** Where lock files live. Machine-global: they coordinate processes. */
19
+ locksDirectory(): string;
20
+ /** Where registry entries live — one small JSON pointer per database. */
21
+ registryDirectory(): string;
22
+ /** Where databases live for projects outside any git repository. */
23
+ databasesDirectory(): string;
24
+ /**
25
+ * Databases written by versions that kept everything under the state root.
26
+ * Present only so they can be listed, adopted, or removed.
27
+ */
28
+ legacyDatabaseDirectories(): string[];
29
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=StateDirectoryPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StateDirectoryPort.js","sourceRoot":"","sources":["../../../src/domain/ports/StateDirectoryPort.ts"],"names":[],"mappings":""}