lmgrep 0.1.17 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/README.md +226 -63
  2. package/completions/_lmgrep +49 -40
  3. package/dist/application/Lmgrep.d.ts +107 -0
  4. package/dist/application/Lmgrep.js +99 -0
  5. package/dist/application/Lmgrep.js.map +1 -0
  6. package/dist/application/LmgrepFactory.d.ts +40 -0
  7. package/dist/application/LmgrepFactory.js +155 -0
  8. package/dist/application/LmgrepFactory.js.map +1 -0
  9. package/dist/application/indexing/BranchBootstrapper.d.ts +21 -0
  10. package/dist/application/indexing/BranchBootstrapper.js +52 -0
  11. package/dist/application/indexing/BranchBootstrapper.js.map +1 -0
  12. package/dist/application/indexing/BranchManifestSweeper.d.ts +17 -0
  13. package/dist/application/indexing/BranchManifestSweeper.js +35 -0
  14. package/dist/application/indexing/BranchManifestSweeper.js.map +1 -0
  15. package/dist/application/indexing/Duration.d.ts +9 -0
  16. package/dist/application/indexing/Duration.js +25 -0
  17. package/dist/application/indexing/Duration.js.map +1 -0
  18. package/dist/application/indexing/EmbeddingAbortError.d.ts +11 -0
  19. package/dist/application/indexing/EmbeddingAbortError.js +20 -0
  20. package/dist/application/indexing/EmbeddingAbortError.js.map +1 -0
  21. package/dist/application/indexing/EmbeddingPipeline.d.ts +59 -0
  22. package/dist/application/indexing/EmbeddingPipeline.js +140 -0
  23. package/dist/application/indexing/EmbeddingPipeline.js.map +1 -0
  24. package/dist/application/indexing/IndexBuilder.d.ts +112 -0
  25. package/dist/application/indexing/IndexBuilder.js +370 -0
  26. package/dist/application/indexing/IndexBuilder.js.map +1 -0
  27. package/dist/application/indexing/IndexingProgress.d.ts +34 -0
  28. package/dist/application/indexing/IndexingProgress.js +2 -0
  29. package/dist/application/indexing/IndexingProgress.js.map +1 -0
  30. package/dist/application/operations/Deadline.d.ts +13 -0
  31. package/dist/application/operations/Deadline.js +29 -0
  32. package/dist/application/operations/Deadline.js.map +1 -0
  33. package/dist/application/operations/HealthMonitor.d.ts +58 -0
  34. package/dist/application/operations/HealthMonitor.js +128 -0
  35. package/dist/application/operations/HealthMonitor.js.map +1 -0
  36. package/dist/application/operations/IndexAlternatives.d.ts +35 -0
  37. package/dist/application/operations/IndexAlternatives.js +61 -0
  38. package/dist/application/operations/IndexAlternatives.js.map +1 -0
  39. package/dist/application/operations/IndexInventory.d.ts +69 -0
  40. package/dist/application/operations/IndexInventory.js +99 -0
  41. package/dist/application/operations/IndexInventory.js.map +1 -0
  42. package/dist/application/operations/StatusService.d.ts +90 -0
  43. package/dist/application/operations/StatusService.js +171 -0
  44. package/dist/application/operations/StatusService.js.map +1 -0
  45. package/dist/application/operations/WatchService.d.ts +67 -0
  46. package/dist/application/operations/WatchService.js +145 -0
  47. package/dist/application/operations/WatchService.js.map +1 -0
  48. package/dist/application/operations/WorkingTreeDiff.d.ts +19 -0
  49. package/dist/application/operations/WorkingTreeDiff.js +36 -0
  50. package/dist/application/operations/WorkingTreeDiff.js.map +1 -0
  51. package/dist/application/research/ResearchAgent.d.ts +68 -0
  52. package/dist/application/research/ResearchAgent.js +201 -0
  53. package/dist/application/research/ResearchAgent.js.map +1 -0
  54. package/dist/application/research/ResearchPrompts.d.ts +16 -0
  55. package/dist/application/research/ResearchPrompts.js +34 -0
  56. package/dist/application/research/ResearchPrompts.js.map +1 -0
  57. package/dist/application/search/SearchCriteria.d.ts +37 -0
  58. package/dist/application/search/SearchCriteria.js +48 -0
  59. package/dist/application/search/SearchCriteria.js.map +1 -0
  60. package/dist/application/search/SearchService.d.ts +36 -0
  61. package/dist/application/search/SearchService.js +108 -0
  62. package/dist/application/search/SearchService.js.map +1 -0
  63. package/dist/application/search/SearchTargetResolver.d.ts +56 -0
  64. package/dist/application/search/SearchTargetResolver.js +104 -0
  65. package/dist/application/search/SearchTargetResolver.js.map +1 -0
  66. package/dist/cli.d.ts +1 -1
  67. package/dist/cli.js +5 -754
  68. package/dist/cli.js.map +1 -1
  69. package/dist/domain/config/ConfigSource.d.ts +16 -0
  70. package/dist/domain/config/ConfigSource.js +2 -0
  71. package/dist/domain/config/ConfigSource.js.map +1 -0
  72. package/dist/domain/config/LmgrepConfig.d.ts +53 -0
  73. package/dist/domain/config/LmgrepConfig.js +2 -0
  74. package/dist/domain/config/LmgrepConfig.js.map +1 -0
  75. package/dist/domain/corpus/Chunk.d.ts +49 -0
  76. package/dist/domain/corpus/Chunk.js +60 -0
  77. package/dist/domain/corpus/Chunk.js.map +1 -0
  78. package/dist/domain/corpus/CodeLocation.d.ts +18 -0
  79. package/dist/domain/corpus/CodeLocation.js +34 -0
  80. package/dist/domain/corpus/CodeLocation.js.map +1 -0
  81. package/dist/domain/corpus/ContentHash.d.ts +15 -0
  82. package/dist/domain/corpus/ContentHash.js +30 -0
  83. package/dist/domain/corpus/ContentHash.js.map +1 -0
  84. package/dist/domain/corpus/FileVersion.d.ts +31 -0
  85. package/dist/domain/corpus/FileVersion.js +47 -0
  86. package/dist/domain/corpus/FileVersion.js.map +1 -0
  87. package/dist/domain/corpus/SourceFile.d.ts +26 -0
  88. package/dist/domain/corpus/SourceFile.js +47 -0
  89. package/dist/domain/corpus/SourceFile.js.map +1 -0
  90. package/dist/domain/corpus/Vector.d.ts +37 -0
  91. package/dist/domain/corpus/Vector.js +96 -0
  92. package/dist/domain/corpus/Vector.js.map +1 -0
  93. package/dist/domain/ports/ChatModelPort.d.ts +57 -0
  94. package/dist/domain/ports/ChatModelPort.js +2 -0
  95. package/dist/domain/ports/ChatModelPort.js.map +1 -0
  96. package/dist/domain/ports/ChunkRepositoryPort.d.ts +42 -0
  97. package/dist/domain/ports/ChunkRepositoryPort.js +2 -0
  98. package/dist/domain/ports/ChunkRepositoryPort.js.map +1 -0
  99. package/dist/domain/ports/ChunkerPort.d.ts +5 -0
  100. package/dist/domain/ports/ChunkerPort.js +2 -0
  101. package/dist/domain/ports/ChunkerPort.js.map +1 -0
  102. package/dist/domain/ports/DatabaseSessionPort.d.ts +10 -0
  103. package/dist/domain/ports/DatabaseSessionPort.js +2 -0
  104. package/dist/domain/ports/DatabaseSessionPort.js.map +1 -0
  105. package/dist/domain/ports/EmbedderPort.d.ts +14 -0
  106. package/dist/domain/ports/EmbedderPort.js +2 -0
  107. package/dist/domain/ports/EmbedderPort.js.map +1 -0
  108. package/dist/domain/ports/FileManifestRepositoryPort.d.ts +32 -0
  109. package/dist/domain/ports/FileManifestRepositoryPort.js +2 -0
  110. package/dist/domain/ports/FileManifestRepositoryPort.js.map +1 -0
  111. package/dist/domain/ports/GitPort.d.ts +24 -0
  112. package/dist/domain/ports/GitPort.js +2 -0
  113. package/dist/domain/ports/GitPort.js.map +1 -0
  114. package/dist/domain/ports/IndexMaintenancePort.d.ts +58 -0
  115. package/dist/domain/ports/IndexMaintenancePort.js +2 -0
  116. package/dist/domain/ports/IndexMaintenancePort.js.map +1 -0
  117. package/dist/domain/ports/IndexMetadataPort.d.ts +23 -0
  118. package/dist/domain/ports/IndexMetadataPort.js +2 -0
  119. package/dist/domain/ports/IndexMetadataPort.js.map +1 -0
  120. package/dist/domain/ports/LockPort.d.ts +17 -0
  121. package/dist/domain/ports/LockPort.js +2 -0
  122. package/dist/domain/ports/LockPort.js.map +1 -0
  123. package/dist/domain/ports/LoggerPort.d.ts +5 -0
  124. package/dist/domain/ports/LoggerPort.js +2 -0
  125. package/dist/domain/ports/LoggerPort.js.map +1 -0
  126. package/dist/domain/ports/ProjectIndexesPort.d.ts +20 -0
  127. package/dist/domain/ports/ProjectIndexesPort.js +2 -0
  128. package/dist/domain/ports/ProjectIndexesPort.js.map +1 -0
  129. package/dist/domain/ports/ProjectRegistryPort.d.ts +42 -0
  130. package/dist/domain/ports/ProjectRegistryPort.js +2 -0
  131. package/dist/domain/ports/ProjectRegistryPort.js.map +1 -0
  132. package/dist/domain/ports/StateDirectoryPort.d.ts +29 -0
  133. package/dist/domain/ports/StateDirectoryPort.js +2 -0
  134. package/dist/domain/ports/StateDirectoryPort.js.map +1 -0
  135. package/dist/domain/ports/WorkspacePort.d.ts +38 -0
  136. package/dist/domain/ports/WorkspacePort.js +2 -0
  137. package/dist/domain/ports/WorkspacePort.js.map +1 -0
  138. package/dist/domain/project/Branch.d.ts +20 -0
  139. package/dist/domain/project/Branch.js +33 -0
  140. package/dist/domain/project/Branch.js.map +1 -0
  141. package/dist/domain/project/DatabaseLocation.d.ts +32 -0
  142. package/dist/domain/project/DatabaseLocation.js +35 -0
  143. package/dist/domain/project/DatabaseLocation.js.map +1 -0
  144. package/dist/domain/project/IndexMetadata.d.ts +17 -0
  145. package/dist/domain/project/IndexMetadata.js +2 -0
  146. package/dist/domain/project/IndexMetadata.js.map +1 -0
  147. package/dist/domain/project/ModelIdentity.d.ts +58 -0
  148. package/dist/domain/project/ModelIdentity.js +97 -0
  149. package/dist/domain/project/ModelIdentity.js.map +1 -0
  150. package/dist/domain/project/Project.d.ts +17 -0
  151. package/dist/domain/project/Project.js +21 -0
  152. package/dist/domain/project/Project.js.map +1 -0
  153. package/dist/domain/project/ProjectId.d.ts +28 -0
  154. package/dist/domain/project/ProjectId.js +58 -0
  155. package/dist/domain/project/ProjectId.js.map +1 -0
  156. package/dist/domain/project/ProjectLocator.d.ts +112 -0
  157. package/dist/domain/project/ProjectLocator.js +178 -0
  158. package/dist/domain/project/ProjectLocator.js.map +1 -0
  159. package/dist/domain/research/Citation.d.ts +27 -0
  160. package/dist/domain/research/Citation.js +43 -0
  161. package/dist/domain/research/Citation.js.map +1 -0
  162. package/dist/domain/research/EvidenceLedger.d.ts +47 -0
  163. package/dist/domain/research/EvidenceLedger.js +111 -0
  164. package/dist/domain/research/EvidenceLedger.js.map +1 -0
  165. package/dist/domain/research/ResearchTrace.d.ts +19 -0
  166. package/dist/domain/research/ResearchTrace.js +22 -0
  167. package/dist/domain/research/ResearchTrace.js.map +1 -0
  168. package/dist/domain/retrieval/Hit.d.ts +19 -0
  169. package/dist/domain/retrieval/Hit.js +28 -0
  170. package/dist/domain/retrieval/Hit.js.map +1 -0
  171. package/dist/domain/retrieval/HitList.d.ts +35 -0
  172. package/dist/domain/retrieval/HitList.js +81 -0
  173. package/dist/domain/retrieval/HitList.js.map +1 -0
  174. package/dist/domain/retrieval/MissingIndexError.d.ts +11 -0
  175. package/dist/domain/retrieval/MissingIndexError.js +15 -0
  176. package/dist/domain/retrieval/MissingIndexError.js.map +1 -0
  177. package/dist/index.d.ts +43 -33
  178. package/dist/index.js +32 -215
  179. package/dist/index.js.map +1 -1
  180. package/dist/infrastructure/ai/AiSdkChatModel.d.ts +31 -0
  181. package/dist/infrastructure/ai/AiSdkChatModel.js +137 -0
  182. package/dist/infrastructure/ai/AiSdkChatModel.js.map +1 -0
  183. package/dist/infrastructure/ai/AiSdkEmbedder.d.ts +28 -0
  184. package/dist/infrastructure/ai/AiSdkEmbedder.js +79 -0
  185. package/dist/infrastructure/ai/AiSdkEmbedder.js.map +1 -0
  186. package/dist/infrastructure/ai/EmbeddingPrefixes.d.ts +21 -0
  187. package/dist/infrastructure/ai/EmbeddingPrefixes.js +40 -0
  188. package/dist/infrastructure/ai/EmbeddingPrefixes.js.map +1 -0
  189. package/dist/infrastructure/ai/LmStudioProbe.d.ts +18 -0
  190. package/dist/infrastructure/ai/LmStudioProbe.js +49 -0
  191. package/dist/infrastructure/ai/LmStudioProbe.js.map +1 -0
  192. package/dist/infrastructure/ai/LocalModelReloader.d.ts +21 -0
  193. package/dist/infrastructure/ai/LocalModelReloader.js +61 -0
  194. package/dist/infrastructure/ai/LocalModelReloader.js.map +1 -0
  195. package/dist/infrastructure/ai/LocalRuntimeDetector.d.ts +36 -0
  196. package/dist/infrastructure/ai/LocalRuntimeDetector.js +61 -0
  197. package/dist/infrastructure/ai/LocalRuntimeDetector.js.map +1 -0
  198. package/dist/infrastructure/ai/ModelRuntime.d.ts +32 -0
  199. package/dist/infrastructure/ai/ModelRuntime.js +2 -0
  200. package/dist/infrastructure/ai/ModelRuntime.js.map +1 -0
  201. package/dist/infrastructure/ai/OllamaProbe.d.ts +21 -0
  202. package/dist/infrastructure/ai/OllamaProbe.js +69 -0
  203. package/dist/infrastructure/ai/OllamaProbe.js.map +1 -0
  204. package/dist/infrastructure/ai/ProviderFailure.d.ts +16 -0
  205. package/dist/infrastructure/ai/ProviderFailure.js +35 -0
  206. package/dist/infrastructure/ai/ProviderFailure.js.map +1 -0
  207. package/dist/infrastructure/ai/ProviderModuleLoader.d.ts +13 -0
  208. package/dist/infrastructure/ai/ProviderModuleLoader.js +49 -0
  209. package/dist/infrastructure/ai/ProviderModuleLoader.js.map +1 -0
  210. package/dist/infrastructure/ai/ProviderRegistry.d.ts +37 -0
  211. package/dist/infrastructure/ai/ProviderRegistry.js +55 -0
  212. package/dist/infrastructure/ai/ProviderRegistry.js.map +1 -0
  213. package/dist/infrastructure/fs/ConfigLoader.d.ts +59 -0
  214. package/dist/infrastructure/fs/ConfigLoader.js +194 -0
  215. package/dist/infrastructure/fs/ConfigLoader.js.map +1 -0
  216. package/dist/infrastructure/fs/DatabaseLocks.d.ts +52 -0
  217. package/dist/infrastructure/fs/DatabaseLocks.js +92 -0
  218. package/dist/infrastructure/fs/DatabaseLocks.js.map +1 -0
  219. package/dist/infrastructure/fs/DiskUsage.d.ts +6 -0
  220. package/dist/infrastructure/fs/DiskUsage.js +41 -0
  221. package/dist/infrastructure/fs/DiskUsage.js.map +1 -0
  222. package/dist/infrastructure/fs/IndexableFileRules.d.ts +33 -0
  223. package/dist/infrastructure/fs/IndexableFileRules.js +177 -0
  224. package/dist/infrastructure/fs/IndexableFileRules.js.map +1 -0
  225. package/dist/infrastructure/fs/Loggers.d.ts +14 -0
  226. package/dist/infrastructure/fs/Loggers.js +18 -0
  227. package/dist/infrastructure/fs/Loggers.js.map +1 -0
  228. package/dist/infrastructure/fs/PidFileLock.d.ts +40 -0
  229. package/dist/infrastructure/fs/PidFileLock.js +97 -0
  230. package/dist/infrastructure/fs/PidFileLock.js.map +1 -0
  231. package/dist/infrastructure/fs/ProjectIndexes.d.ts +8 -0
  232. package/dist/infrastructure/fs/ProjectIndexes.js +35 -0
  233. package/dist/infrastructure/fs/ProjectIndexes.js.map +1 -0
  234. package/dist/infrastructure/fs/ProjectMetadataStore.d.ts +42 -0
  235. package/dist/infrastructure/fs/ProjectMetadataStore.js +86 -0
  236. package/dist/infrastructure/fs/ProjectMetadataStore.js.map +1 -0
  237. package/dist/infrastructure/fs/ProjectRegistry.d.ts +25 -0
  238. package/dist/infrastructure/fs/ProjectRegistry.js +83 -0
  239. package/dist/infrastructure/fs/ProjectRegistry.js.map +1 -0
  240. package/dist/infrastructure/fs/StateDirectory.d.ts +28 -0
  241. package/dist/infrastructure/fs/StateDirectory.js +71 -0
  242. package/dist/infrastructure/fs/StateDirectory.js.map +1 -0
  243. package/dist/infrastructure/fs/Workspace.d.ts +25 -0
  244. package/dist/infrastructure/fs/Workspace.js +90 -0
  245. package/dist/infrastructure/fs/Workspace.js.map +1 -0
  246. package/dist/infrastructure/git/GitClient.d.ts +34 -0
  247. package/dist/infrastructure/git/GitClient.js +74 -0
  248. package/dist/infrastructure/git/GitClient.js.map +1 -0
  249. package/dist/infrastructure/lancedb/ChunkRepository.d.ts +38 -0
  250. package/dist/infrastructure/lancedb/ChunkRepository.js +166 -0
  251. package/dist/infrastructure/lancedb/ChunkRepository.js.map +1 -0
  252. package/dist/infrastructure/lancedb/DatabaseImporter.d.ts +22 -0
  253. package/dist/infrastructure/lancedb/DatabaseImporter.js +74 -0
  254. package/dist/infrastructure/lancedb/DatabaseImporter.js.map +1 -0
  255. package/dist/infrastructure/lancedb/FileManifestRepository.d.ts +34 -0
  256. package/dist/infrastructure/lancedb/FileManifestRepository.js +137 -0
  257. package/dist/infrastructure/lancedb/FileManifestRepository.js.map +1 -0
  258. package/dist/infrastructure/lancedb/IndexMaintenance.d.ts +53 -0
  259. package/dist/infrastructure/lancedb/IndexMaintenance.js +227 -0
  260. package/dist/infrastructure/lancedb/IndexMaintenance.js.map +1 -0
  261. package/dist/infrastructure/lancedb/LanceTables.d.ts +67 -0
  262. package/dist/infrastructure/lancedb/LanceTables.js +159 -0
  263. package/dist/infrastructure/lancedb/LanceTables.js.map +1 -0
  264. package/dist/infrastructure/lancedb/NativeTuning.d.ts +1 -0
  265. package/dist/infrastructure/lancedb/NativeTuning.js +9 -0
  266. package/dist/infrastructure/lancedb/NativeTuning.js.map +1 -0
  267. package/dist/infrastructure/lancedb/RowReplication.d.ts +27 -0
  268. package/dist/infrastructure/lancedb/RowReplication.js +82 -0
  269. package/dist/infrastructure/lancedb/RowReplication.js.map +1 -0
  270. package/dist/infrastructure/lancedb/VectorIndexPolicy.d.ts +60 -0
  271. package/dist/infrastructure/lancedb/VectorIndexPolicy.js +72 -0
  272. package/dist/infrastructure/lancedb/VectorIndexPolicy.js.map +1 -0
  273. package/dist/infrastructure/p2p/IndexShare.d.ts +45 -0
  274. package/dist/infrastructure/p2p/IndexShare.js +160 -0
  275. package/dist/infrastructure/p2p/IndexShare.js.map +1 -0
  276. package/dist/infrastructure/p2p/PeerSwarm.d.ts +16 -0
  277. package/dist/infrastructure/p2p/PeerSwarm.js +41 -0
  278. package/dist/infrastructure/p2p/PeerSwarm.js.map +1 -0
  279. package/dist/infrastructure/p2p/SecureChannel.d.ts +60 -0
  280. package/dist/infrastructure/p2p/SecureChannel.js +71 -0
  281. package/dist/infrastructure/p2p/SecureChannel.js.map +1 -0
  282. package/dist/infrastructure/p2p/ShareCode.d.ts +25 -0
  283. package/dist/infrastructure/p2p/ShareCode.js +304 -0
  284. package/dist/infrastructure/p2p/ShareCode.js.map +1 -0
  285. package/dist/infrastructure/process/ProcessRegistry.d.ts +50 -0
  286. package/dist/infrastructure/process/ProcessRegistry.js +109 -0
  287. package/dist/infrastructure/process/ProcessRegistry.js.map +1 -0
  288. package/dist/infrastructure/treesitter/ChunkContextBuilder.d.ts +45 -0
  289. package/dist/infrastructure/treesitter/ChunkContextBuilder.js +159 -0
  290. package/dist/infrastructure/treesitter/ChunkContextBuilder.js.map +1 -0
  291. package/dist/infrastructure/treesitter/LanguageCatalog.d.ts +30 -0
  292. package/dist/{lib/chunker/languages.js → infrastructure/treesitter/LanguageCatalog.js} +65 -41
  293. package/dist/infrastructure/treesitter/LanguageCatalog.js.map +1 -0
  294. package/dist/infrastructure/treesitter/SlidingWindowChunker.d.ts +15 -0
  295. package/dist/infrastructure/treesitter/SlidingWindowChunker.js +42 -0
  296. package/dist/infrastructure/treesitter/SlidingWindowChunker.js.map +1 -0
  297. package/dist/infrastructure/treesitter/TreeSitterChunker.d.ts +42 -0
  298. package/dist/infrastructure/treesitter/TreeSitterChunker.js +163 -0
  299. package/dist/infrastructure/treesitter/TreeSitterChunker.js.map +1 -0
  300. package/dist/mcp.d.ts +1 -1
  301. package/dist/mcp.js +15 -61
  302. package/dist/mcp.js.map +1 -1
  303. package/dist/presentation/cli/Cli.d.ts +31 -0
  304. package/dist/presentation/cli/Cli.js +120 -0
  305. package/dist/presentation/cli/Cli.js.map +1 -0
  306. package/dist/presentation/cli/CliOptions.d.ts +18 -0
  307. package/dist/presentation/cli/CliOptions.js +25 -0
  308. package/dist/presentation/cli/CliOptions.js.map +1 -0
  309. package/dist/presentation/cli/CommandContext.d.ts +50 -0
  310. package/dist/presentation/cli/CommandContext.js +88 -0
  311. package/dist/presentation/cli/CommandContext.js.map +1 -0
  312. package/dist/presentation/cli/ConfigTemplate.d.ts +31 -0
  313. package/dist/presentation/cli/ConfigTemplate.js +83 -0
  314. package/dist/presentation/cli/ConfigTemplate.js.map +1 -0
  315. package/dist/presentation/cli/Renderer.d.ts +90 -0
  316. package/dist/presentation/cli/Renderer.js +290 -0
  317. package/dist/presentation/cli/Renderer.js.map +1 -0
  318. package/dist/presentation/cli/commands/AskCommand.d.ts +14 -0
  319. package/dist/presentation/cli/commands/AskCommand.js +48 -0
  320. package/dist/presentation/cli/commands/AskCommand.js.map +1 -0
  321. package/dist/presentation/cli/commands/CompletionsCommand.d.ts +18 -0
  322. package/dist/presentation/cli/commands/CompletionsCommand.js +96 -0
  323. package/dist/presentation/cli/commands/CompletionsCommand.js.map +1 -0
  324. package/dist/presentation/cli/commands/ConfigCommands.d.ts +55 -0
  325. package/dist/presentation/cli/commands/ConfigCommands.js +204 -0
  326. package/dist/presentation/cli/commands/ConfigCommands.js.map +1 -0
  327. package/dist/presentation/cli/commands/IndexCommand.d.ts +18 -0
  328. package/dist/presentation/cli/commands/IndexCommand.js +54 -0
  329. package/dist/presentation/cli/commands/IndexCommand.js.map +1 -0
  330. package/dist/presentation/cli/commands/ProjectsCommand.d.ts +48 -0
  331. package/dist/presentation/cli/commands/ProjectsCommand.js +240 -0
  332. package/dist/presentation/cli/commands/ProjectsCommand.js.map +1 -0
  333. package/dist/presentation/cli/commands/SearchCommand.d.ts +19 -0
  334. package/dist/presentation/cli/commands/SearchCommand.js +55 -0
  335. package/dist/presentation/cli/commands/SearchCommand.js.map +1 -0
  336. package/dist/presentation/cli/commands/ServerCommands.d.ts +13 -0
  337. package/dist/presentation/cli/commands/ServerCommands.js +40 -0
  338. package/dist/presentation/cli/commands/ServerCommands.js.map +1 -0
  339. package/dist/presentation/cli/commands/ShareCommands.d.ts +22 -0
  340. package/dist/presentation/cli/commands/ShareCommands.js +134 -0
  341. package/dist/presentation/cli/commands/ShareCommands.js.map +1 -0
  342. package/dist/presentation/cli/commands/StatusCommand.d.ts +15 -0
  343. package/dist/presentation/cli/commands/StatusCommand.js +53 -0
  344. package/dist/presentation/cli/commands/StatusCommand.js.map +1 -0
  345. package/dist/presentation/mcp/HitFormatter.d.ts +17 -0
  346. package/dist/presentation/mcp/HitFormatter.js +42 -0
  347. package/dist/presentation/mcp/HitFormatter.js.map +1 -0
  348. package/dist/presentation/mcp/IndexWatchController.d.ts +17 -0
  349. package/dist/presentation/mcp/IndexWatchController.js +31 -0
  350. package/dist/presentation/mcp/IndexWatchController.js.map +1 -0
  351. package/dist/presentation/mcp/LmgrepCore.d.ts +66 -0
  352. package/dist/presentation/mcp/LmgrepCore.js +178 -0
  353. package/dist/presentation/mcp/LmgrepCore.js.map +1 -0
  354. package/dist/presentation/mcp/McpServer.d.ts +18 -0
  355. package/dist/presentation/mcp/McpServer.js +63 -0
  356. package/dist/presentation/mcp/McpServer.js.map +1 -0
  357. package/dist/presentation/mcp/ToolDescriptions.d.ts +40 -0
  358. package/dist/presentation/mcp/ToolDescriptions.js +85 -0
  359. package/dist/presentation/mcp/ToolDescriptions.js.map +1 -0
  360. package/package.json +84 -63
  361. package/dist/lib/build.d.ts +0 -7
  362. package/dist/lib/build.js +0 -284
  363. package/dist/lib/build.js.map +0 -1
  364. package/dist/lib/chunker/context.d.ts +0 -21
  365. package/dist/lib/chunker/context.js +0 -131
  366. package/dist/lib/chunker/context.js.map +0 -1
  367. package/dist/lib/chunker/index.d.ts +0 -7
  368. package/dist/lib/chunker/index.js +0 -150
  369. package/dist/lib/chunker/index.js.map +0 -1
  370. package/dist/lib/chunker/languages.d.ts +0 -15
  371. package/dist/lib/chunker/languages.js.map +0 -1
  372. package/dist/lib/config.d.ts +0 -12
  373. package/dist/lib/config.js +0 -83
  374. package/dist/lib/config.js.map +0 -1
  375. package/dist/lib/embedder.d.ts +0 -55
  376. package/dist/lib/embedder.js +0 -221
  377. package/dist/lib/embedder.js.map +0 -1
  378. package/dist/lib/p2p.d.ts +0 -32
  379. package/dist/lib/p2p.js +0 -281
  380. package/dist/lib/p2p.js.map +0 -1
  381. package/dist/lib/providers.d.ts +0 -1
  382. package/dist/lib/providers.js +0 -41
  383. package/dist/lib/providers.js.map +0 -1
  384. package/dist/lib/repair.d.ts +0 -10
  385. package/dist/lib/repair.js +0 -57
  386. package/dist/lib/repair.js.map +0 -1
  387. package/dist/lib/scanner.d.ts +0 -34
  388. package/dist/lib/scanner.js +0 -242
  389. package/dist/lib/scanner.js.map +0 -1
  390. package/dist/lib/search-tool.d.ts +0 -47
  391. package/dist/lib/search-tool.js +0 -239
  392. package/dist/lib/search-tool.js.map +0 -1
  393. package/dist/lib/serve.d.ts +0 -11
  394. package/dist/lib/serve.js +0 -127
  395. package/dist/lib/serve.js.map +0 -1
  396. package/dist/lib/store.d.ts +0 -177
  397. package/dist/lib/store.js +0 -825
  398. package/dist/lib/store.js.map +0 -1
  399. package/dist/lib/types.d.ts +0 -129
  400. package/dist/lib/types.js +0 -13
  401. package/dist/lib/types.js.map +0 -1
@@ -0,0 +1,38 @@
1
+ import type { ContentHash } from "../corpus/ContentHash.js";
2
+ import type { SourceFile } from "../corpus/SourceFile.js";
3
+ /** Extension include/exclude overrides layered on the built-in set. */
4
+ export interface ExtensionRules {
5
+ include?: string[];
6
+ exclude?: string[];
7
+ }
8
+ /** Stops a running watch. */
9
+ export interface WatchHandle {
10
+ close(): void;
11
+ }
12
+ /** Files whose on-disk hash differs from what the manifest recorded. */
13
+ export interface ChangeSet {
14
+ changed: SourceFile[];
15
+ /** Hash of every readable file scanned, changed or not. */
16
+ current: Map<string, ContentHash>;
17
+ }
18
+ /**
19
+ * The working tree: which files exist, what they contain, and when they
20
+ * change. The indexer talks to this rather than to `node:fs` directly.
21
+ */
22
+ export interface WorkspacePort {
23
+ /** Indexable files under `cwd`, honouring ignore rules and extensions. */
24
+ listFiles(cwd: string, extraIgnore?: string[], extensions?: ExtensionRules): string[];
25
+ /** Content hash of one file, or undefined when it cannot be read. */
26
+ hashOf(cwd: string, filePath: string): ContentHash | undefined;
27
+ /** Keep only files modified at or after `cutoffMs`. */
28
+ modifiedSince(files: string[], cwd: string, cutoffMs: number): string[];
29
+ /**
30
+ * Compare on-disk hashes against a manifest, reporting what differs.
31
+ * `force` treats every readable file as changed.
32
+ */
33
+ detectChanges(files: string[], manifest: {
34
+ versionOf(path: string): ContentHash | undefined;
35
+ }, cwd: string, force?: boolean): ChangeSet;
36
+ /** Watch for changes, debounced, reporting the paths that changed. */
37
+ watch(cwd: string, extraIgnore: string[] | undefined, onChanges: (changedFiles: string[]) => void, debounceMs: number, extensions?: ExtensionRules): WatchHandle;
38
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=WorkspacePort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkspacePort.js","sourceRoot":"","sources":["../../../src/domain/ports/WorkspacePort.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A branch scope for reads and writes.
3
+ *
4
+ * Chunks are shared across branches by content hash; the file manifest is what
5
+ * is branch-scoped. A manually targeted database is flat — it uses
6
+ * {@link Branch.DEFAULT} so switching git branches never hides results in a
7
+ * database the user asked for by name or path.
8
+ */
9
+ export declare class Branch {
10
+ private readonly name;
11
+ /** Scope used by non-git projects and manually targeted databases. */
12
+ static readonly DEFAULT_NAME = "_default";
13
+ private constructor();
14
+ static of(name: string): Branch;
15
+ static default(): Branch;
16
+ toString(): string;
17
+ equals(other: Branch): boolean;
18
+ /** Single-quote-escaped for embedding in a LanceDB filter predicate. */
19
+ toSqlLiteral(): string;
20
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A branch scope for reads and writes.
3
+ *
4
+ * Chunks are shared across branches by content hash; the file manifest is what
5
+ * is branch-scoped. A manually targeted database is flat — it uses
6
+ * {@link Branch.DEFAULT} so switching git branches never hides results in a
7
+ * database the user asked for by name or path.
8
+ */
9
+ export class Branch {
10
+ name;
11
+ /** Scope used by non-git projects and manually targeted databases. */
12
+ static DEFAULT_NAME = "_default";
13
+ constructor(name) {
14
+ this.name = name;
15
+ }
16
+ static of(name) {
17
+ return new Branch(name);
18
+ }
19
+ static default() {
20
+ return new Branch(Branch.DEFAULT_NAME);
21
+ }
22
+ toString() {
23
+ return this.name;
24
+ }
25
+ equals(other) {
26
+ return this.name === other.name;
27
+ }
28
+ /** Single-quote-escaped for embedding in a LanceDB filter predicate. */
29
+ toSqlLiteral() {
30
+ return this.name.replace(/'/g, "''");
31
+ }
32
+ }
33
+ //# sourceMappingURL=Branch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Branch.js","sourceRoot":"","sources":["../../../src/domain/project/Branch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,MAAM;IAImB;IAHrC,sEAAsE;IACtE,MAAM,CAAU,YAAY,GAAG,UAAU,CAAC;IAE1C,YAAqC,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAErD,MAAM,CAAC,EAAE,CAAC,IAAY;QACrB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,OAAO;QACb,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,KAAa;QACnB,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,wEAAwE;IACxE,YAAY;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { Branch } from "./Branch.js";
2
+ /**
3
+ * The fully-resolved database a command reads from and writes to.
4
+ *
5
+ * `manual` records how it was chosen, because that changes behaviour
6
+ * downstream: a manually targeted database is flat (no branch scoping, no
7
+ * ancestor prefix walking), while the git-aware default participates in both.
8
+ */
9
+ export declare class DatabaseLocation {
10
+ /** Absolute path to the database directory. */
11
+ readonly path: string;
12
+ /** Branch scope to read and write. */
13
+ readonly branch: Branch;
14
+ /** Project root used for metadata and status display. */
15
+ readonly root: string;
16
+ /** True when chosen explicitly via `--database`. */
17
+ readonly manual: boolean;
18
+ constructor(
19
+ /** Absolute path to the database directory. */
20
+ path: string,
21
+ /** Branch scope to read and write. */
22
+ branch: Branch,
23
+ /** Project root used for metadata and status display. */
24
+ root: string,
25
+ /** True when chosen explicitly via `--database`. */
26
+ manual: boolean);
27
+ /**
28
+ * Whether this database participates in branch scoping and ancestor
29
+ * resolution. False for `--database` targets, which are deliberately flat.
30
+ */
31
+ get isGitAware(): boolean;
32
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The fully-resolved database a command reads from and writes to.
3
+ *
4
+ * `manual` records how it was chosen, because that changes behaviour
5
+ * downstream: a manually targeted database is flat (no branch scoping, no
6
+ * ancestor prefix walking), while the git-aware default participates in both.
7
+ */
8
+ export class DatabaseLocation {
9
+ path;
10
+ branch;
11
+ root;
12
+ manual;
13
+ constructor(
14
+ /** Absolute path to the database directory. */
15
+ path,
16
+ /** Branch scope to read and write. */
17
+ branch,
18
+ /** Project root used for metadata and status display. */
19
+ root,
20
+ /** True when chosen explicitly via `--database`. */
21
+ manual) {
22
+ this.path = path;
23
+ this.branch = branch;
24
+ this.root = root;
25
+ this.manual = manual;
26
+ }
27
+ /**
28
+ * Whether this database participates in branch scoping and ancestor
29
+ * resolution. False for `--database` targets, which are deliberately flat.
30
+ */
31
+ get isGitAware() {
32
+ return !this.manual;
33
+ }
34
+ }
35
+ //# sourceMappingURL=DatabaseLocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseLocation.js","sourceRoot":"","sources":["../../../src/domain/project/DatabaseLocation.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAGlB;IAEA;IAEA;IAEA;IARV;IACC,+CAA+C;IACtC,IAAY;IACrB,sCAAsC;IAC7B,MAAc;IACvB,yDAAyD;IAChD,IAAY;IACrB,oDAAoD;IAC3C,MAAe;QANf,SAAI,GAAJ,IAAI,CAAQ;QAEZ,WAAM,GAAN,MAAM,CAAQ;QAEd,SAAI,GAAJ,IAAI,CAAQ;QAEZ,WAAM,GAAN,MAAM,CAAS;IACtB,CAAC;IAEJ;;;OAGG;IACH,IAAI,UAAU;QACb,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACD"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * What an index records about itself: where it came from and how it was built.
3
+ *
4
+ * The model and dimensions are the important part — they are what lets a later
5
+ * search detect that it is querying with incompatible embeddings instead of
6
+ * silently returning nonsense.
7
+ */
8
+ export interface IndexMetadata {
9
+ root: string;
10
+ remote?: string;
11
+ branch: string;
12
+ indexedAt: string;
13
+ /** Full model string used at index time (e.g. "openai:nomic-embed-text"). */
14
+ model?: string;
15
+ /** Embedding vector dimensions. */
16
+ dimensions?: number;
17
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IndexMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndexMetadata.js","sourceRoot":"","sources":["../../../src/domain/project/IndexMetadata.ts"],"names":[],"mappings":""}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * A model string in `provider:model` form, the family comparison that decides
3
+ * whether two models produce interchangeable embeddings, and the directory
4
+ * slug derived from it.
5
+ *
6
+ * Only the family matters: a re-quantized or re-tagged build of the same model
7
+ * produces compatible embeddings, and so does the same model served by a
8
+ * different runtime, so comparing raw strings would partition on differences
9
+ * that do not exist.
10
+ *
11
+ * The slug is the load-bearing part. Databases are stored per model, so
12
+ * {@link toSlug} draws the boundary between them — and it must draw it in
13
+ * exactly the same place as {@link isSameFamilyAs}. Two models share a
14
+ * database if and only if they are compatible; a slug that split more finely
15
+ * would re-embed a corpus for nothing, and one that split more coarsely would
16
+ * mix incomparable vectors into one table.
17
+ */
18
+ export declare class ModelIdentity {
19
+ private readonly value;
20
+ /** Quantization and tag suffixes that do not change the embedding space. */
21
+ private static readonly VARIANT_SUFFIX;
22
+ /** Long enough to stay readable in a path, short enough to stay a path. */
23
+ private static readonly SLUG_PREFIX_LENGTH;
24
+ private static readonly SLUG_HASH_LENGTH;
25
+ private constructor();
26
+ static of(model: string): ModelIdentity;
27
+ toString(): string;
28
+ /** Provider segment, or undefined when the string carries none. */
29
+ get provider(): string | undefined;
30
+ /**
31
+ * The model name with the provider prefix and any variant suffix removed.
32
+ *
33
+ * "openai:nomic-embed-text" -> "nomic-embed-text"
34
+ * "ollama:nomic-embed-text:Q4_K_M" -> "nomic-embed-text"
35
+ * "lmstudio:bge-large-en:fp16" -> "bge-large-en"
36
+ */
37
+ get family(): string;
38
+ /** Whether two models produce interchangeable embeddings. */
39
+ isSameFamilyAs(other: ModelIdentity): boolean;
40
+ /**
41
+ * Directory name holding this model's embeddings.
42
+ *
43
+ * Built from the family rather than the full string, so switching runtimes
44
+ * (`ollama:` to `lmstudio:`) or pulling a new quantization reuses the index
45
+ * instead of silently re-embedding the repository.
46
+ *
47
+ * `dimensions` is part of the identity because a model with configurable
48
+ * output width produces vectors that cannot be compared across widths —
49
+ * same family, different space. It is the one axis {@link isSameFamilyAs}
50
+ * cannot see, so it is folded in here.
51
+ *
52
+ * The trailing hash is what actually guarantees uniqueness: the readable
53
+ * prefix is truncated, sanitized, and compared case-insensitively by macOS
54
+ * and Windows filesystems, so it cannot be relied on to separate two
55
+ * models on its own.
56
+ */
57
+ toSlug(dimensions?: number): string;
58
+ }
@@ -0,0 +1,97 @@
1
+ import { createHash } from "node:crypto";
2
+ /**
3
+ * A model string in `provider:model` form, the family comparison that decides
4
+ * whether two models produce interchangeable embeddings, and the directory
5
+ * slug derived from it.
6
+ *
7
+ * Only the family matters: a re-quantized or re-tagged build of the same model
8
+ * produces compatible embeddings, and so does the same model served by a
9
+ * different runtime, so comparing raw strings would partition on differences
10
+ * that do not exist.
11
+ *
12
+ * The slug is the load-bearing part. Databases are stored per model, so
13
+ * {@link toSlug} draws the boundary between them — and it must draw it in
14
+ * exactly the same place as {@link isSameFamilyAs}. Two models share a
15
+ * database if and only if they are compatible; a slug that split more finely
16
+ * would re-embed a corpus for nothing, and one that split more coarsely would
17
+ * mix incomparable vectors into one table.
18
+ */
19
+ export class ModelIdentity {
20
+ value;
21
+ /** Quantization and tag suffixes that do not change the embedding space. */
22
+ static VARIANT_SUFFIX = /^(Q\d|q\d|fp\d|f\d|latest|gguf|ggml)/i;
23
+ /** Long enough to stay readable in a path, short enough to stay a path. */
24
+ static SLUG_PREFIX_LENGTH = 48;
25
+ static SLUG_HASH_LENGTH = 8;
26
+ constructor(value) {
27
+ this.value = value;
28
+ }
29
+ static of(model) {
30
+ return new ModelIdentity(model);
31
+ }
32
+ toString() {
33
+ return this.value;
34
+ }
35
+ /** Provider segment, or undefined when the string carries none. */
36
+ get provider() {
37
+ const colon = this.value.indexOf(":");
38
+ return colon === -1 ? undefined : this.value.slice(0, colon);
39
+ }
40
+ /**
41
+ * The model name with the provider prefix and any variant suffix removed.
42
+ *
43
+ * "openai:nomic-embed-text" -> "nomic-embed-text"
44
+ * "ollama:nomic-embed-text:Q4_K_M" -> "nomic-embed-text"
45
+ * "lmstudio:bge-large-en:fp16" -> "bge-large-en"
46
+ */
47
+ get family() {
48
+ const colon = this.value.indexOf(":");
49
+ if (colon === -1)
50
+ return this.value;
51
+ const rest = this.value.slice(colon + 1);
52
+ const lastColon = rest.lastIndexOf(":");
53
+ if (lastColon === -1)
54
+ return rest;
55
+ const suffix = rest.slice(lastColon + 1);
56
+ if (ModelIdentity.VARIANT_SUFFIX.test(suffix)) {
57
+ return rest.slice(0, lastColon);
58
+ }
59
+ // Unrecognized trailing segment — likely part of the name itself.
60
+ return rest;
61
+ }
62
+ /** Whether two models produce interchangeable embeddings. */
63
+ isSameFamilyAs(other) {
64
+ return this.family === other.family;
65
+ }
66
+ /**
67
+ * Directory name holding this model's embeddings.
68
+ *
69
+ * Built from the family rather than the full string, so switching runtimes
70
+ * (`ollama:` to `lmstudio:`) or pulling a new quantization reuses the index
71
+ * instead of silently re-embedding the repository.
72
+ *
73
+ * `dimensions` is part of the identity because a model with configurable
74
+ * output width produces vectors that cannot be compared across widths —
75
+ * same family, different space. It is the one axis {@link isSameFamilyAs}
76
+ * cannot see, so it is folded in here.
77
+ *
78
+ * The trailing hash is what actually guarantees uniqueness: the readable
79
+ * prefix is truncated, sanitized, and compared case-insensitively by macOS
80
+ * and Windows filesystems, so it cannot be relied on to separate two
81
+ * models on its own.
82
+ */
83
+ toSlug(dimensions) {
84
+ const identity = dimensions ? `${this.family}@${dimensions}` : this.family;
85
+ const hash = createHash("sha256")
86
+ .update(identity)
87
+ .digest("hex")
88
+ .slice(0, ModelIdentity.SLUG_HASH_LENGTH);
89
+ const readable = this.family
90
+ .replace(/[^a-zA-Z0-9._-]/g, "-")
91
+ .replace(/-+/g, "-")
92
+ .replace(/^-|-$/g, "")
93
+ .slice(0, ModelIdentity.SLUG_PREFIX_LENGTH);
94
+ return readable.length > 0 ? `${readable}-${hash}` : hash;
95
+ }
96
+ }
97
+ //# sourceMappingURL=ModelIdentity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelIdentity.js","sourceRoot":"","sources":["../../../src/domain/project/ModelIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,aAAa;IASY;IARrC,4EAA4E;IACpE,MAAM,CAAU,cAAc,GACrC,uCAAuC,CAAC;IAEzC,2EAA2E;IACnE,MAAM,CAAU,kBAAkB,GAAG,EAAE,CAAC;IACxC,MAAM,CAAU,gBAAgB,GAAG,CAAC,CAAC;IAE7C,YAAqC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAEtD,MAAM,CAAC,EAAE,CAAC,KAAa;QACtB,OAAO,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,mEAAmE;IACnE,IAAI,QAAQ;QACX,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;OAMG;IACH,IAAI,MAAM;QACT,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAEzC,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACxC,IAAI,SAAS,KAAK,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QAElC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;QACzC,IAAI,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;QACjC,CAAC;QACD,kEAAkE;QAClE,OAAO,IAAI,CAAC;IACb,CAAC;IAED,6DAA6D;IAC7D,cAAc,CAAC,KAAoB;QAClC,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC;IACrC,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,UAAmB;QACzB,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAC3E,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC;aAC/B,MAAM,CAAC,QAAQ,CAAC;aAChB,MAAM,CAAC,KAAK,CAAC;aACb,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM;aAC1B,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC;aAChC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;aACrB,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;QAC7C,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3D,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { Branch } from "./Branch.js";
2
+ import type { ProjectId } from "./ProjectId.js";
3
+ /** A resolved project: its identity, working-tree root and current branch. */
4
+ export declare class Project {
5
+ readonly id: ProjectId;
6
+ /** Git toplevel, or the absolute directory outside a repo. */
7
+ readonly root: string;
8
+ readonly branch: Branch;
9
+ /** Origin remote URL, when the project has one. */
10
+ readonly remote?: string | undefined;
11
+ constructor(id: ProjectId,
12
+ /** Git toplevel, or the absolute directory outside a repo. */
13
+ root: string, branch: Branch,
14
+ /** Origin remote URL, when the project has one. */
15
+ remote?: string | undefined);
16
+ get isGitRepository(): boolean;
17
+ }
@@ -0,0 +1,21 @@
1
+ /** A resolved project: its identity, working-tree root and current branch. */
2
+ export class Project {
3
+ id;
4
+ root;
5
+ branch;
6
+ remote;
7
+ constructor(id,
8
+ /** Git toplevel, or the absolute directory outside a repo. */
9
+ root, branch,
10
+ /** Origin remote URL, when the project has one. */
11
+ remote) {
12
+ this.id = id;
13
+ this.root = root;
14
+ this.branch = branch;
15
+ this.remote = remote;
16
+ }
17
+ get isGitRepository() {
18
+ return this.remote !== undefined || this.branch.toString() !== "_default";
19
+ }
20
+ }
21
+ //# sourceMappingURL=Project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Project.js","sourceRoot":"","sources":["../../../src/domain/project/Project.ts"],"names":[],"mappings":"AAGA,8EAA8E;AAC9E,MAAM,OAAO,OAAO;IAET;IAEA;IACA;IAEA;IANV,YACU,EAAa;IACtB,8DAA8D;IACrD,IAAY,EACZ,MAAc;IACvB,mDAAmD;IAC1C,MAAe;QALf,OAAE,GAAF,EAAE,CAAW;QAEb,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QAEd,WAAM,GAAN,MAAM,CAAS;IACtB,CAAC;IAEJ,IAAI,eAAe;QAClB,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,UAAU,CAAC;IAC3E,CAAC;CACD"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The identity of a project, and the on-disk slug derived from it.
3
+ *
4
+ * Identity is the git remote URL when there is one, so every worktree and
5
+ * clone of the same repository shares a single index. Without a remote it
6
+ * falls back to the git root, and outside git to the absolute path.
7
+ */
8
+ export declare class ProjectId {
9
+ private readonly value;
10
+ private constructor();
11
+ static of(value: string): ProjectId;
12
+ toString(): string;
13
+ equals(other: ProjectId): boolean;
14
+ /**
15
+ * Directory name for this project's database: a readable prefix plus a hash
16
+ * of the full identity. The prefix is for humans browsing the state
17
+ * directory; the hash is what actually guarantees uniqueness.
18
+ */
19
+ toSlug(): string;
20
+ /**
21
+ * Strip the git URL scheme and any trailing `.git` so worktrees of one repo
22
+ * produce the same prefix regardless of where they live on disk.
23
+ * git@host:user/repo.git -> user-repo
24
+ * https://host/user/repo.git -> user-repo
25
+ * /abs/path/to/project -> to-project
26
+ */
27
+ private readablePrefix;
28
+ }
@@ -0,0 +1,58 @@
1
+ import { createHash } from "node:crypto";
2
+ /**
3
+ * The identity of a project, and the on-disk slug derived from it.
4
+ *
5
+ * Identity is the git remote URL when there is one, so every worktree and
6
+ * clone of the same repository shares a single index. Without a remote it
7
+ * falls back to the git root, and outside git to the absolute path.
8
+ */
9
+ export class ProjectId {
10
+ value;
11
+ constructor(value) {
12
+ this.value = value;
13
+ }
14
+ static of(value) {
15
+ return new ProjectId(value);
16
+ }
17
+ toString() {
18
+ return this.value;
19
+ }
20
+ equals(other) {
21
+ return this.value === other.value;
22
+ }
23
+ /**
24
+ * Directory name for this project's database: a readable prefix plus a hash
25
+ * of the full identity. The prefix is for humans browsing the state
26
+ * directory; the hash is what actually guarantees uniqueness.
27
+ */
28
+ toSlug() {
29
+ const hash = createHash("sha256")
30
+ .update(this.value)
31
+ .digest("hex")
32
+ .slice(0, 8);
33
+ return `${this.readablePrefix()}-${hash}`;
34
+ }
35
+ /**
36
+ * Strip the git URL scheme and any trailing `.git` so worktrees of one repo
37
+ * produce the same prefix regardless of where they live on disk.
38
+ * git@host:user/repo.git -> user-repo
39
+ * https://host/user/repo.git -> user-repo
40
+ * /abs/path/to/project -> to-project
41
+ */
42
+ readablePrefix() {
43
+ let s = this.value.replace(/\.git$/, "");
44
+ const scpMatch = s.match(/^[^@]+@[^:]+:(.+)$/);
45
+ if (scpMatch) {
46
+ s = scpMatch[1];
47
+ }
48
+ else {
49
+ s = s.replace(/^[a-z]+:\/\/[^/]+\//, "");
50
+ }
51
+ const parts = s.split("/").filter(Boolean);
52
+ return parts
53
+ .slice(-2)
54
+ .join("-")
55
+ .replace(/[^a-zA-Z0-9_-]/g, "_");
56
+ }
57
+ }
58
+ //# sourceMappingURL=ProjectId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProjectId.js","sourceRoot":"","sources":["../../../src/domain/project/ProjectId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,OAAO,SAAS;IACgB;IAArC,YAAqC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAEtD,MAAM,CAAC,EAAE,CAAC,KAAa;QACtB,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,KAAgB;QACtB,OAAO,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,MAAM;QACL,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC;aAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aAClB,MAAM,CAAC,KAAK,CAAC;aACb,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACd,OAAO,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,IAAI,EAAE,CAAC;IAC3C,CAAC;IAED;;;;;;OAMG;IACK,cAAc;QACrB,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC/C,IAAI,QAAQ,EAAE,CAAC;YACd,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;aAAM,CAAC;YACP,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;QACD,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3C,OAAO,KAAK;aACV,KAAK,CAAC,CAAC,CAAC,CAAC;aACT,IAAI,CAAC,GAAG,CAAC;aACT,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;CACD"}
@@ -0,0 +1,112 @@
1
+ import type { GitPort } from "../ports/GitPort.js";
2
+ import type { StateDirectoryPort } from "../ports/StateDirectoryPort.js";
3
+ import { DatabaseLocation } from "./DatabaseLocation.js";
4
+ import type { ModelIdentity } from "./ModelIdentity.js";
5
+ import { Project } from "./Project.js";
6
+ /** Where a working directory sits relative to the indexed project root. */
7
+ export interface IndexedAncestor {
8
+ root: string;
9
+ /** Subdirectory offset from the root, "" when they are the same. */
10
+ prefix: string;
11
+ }
12
+ /**
13
+ * Translates a working directory into a project identity and a database
14
+ * location.
15
+ *
16
+ * This is the only place that knows the rules, and there are three:
17
+ *
18
+ * **A repository's index lives inside it**, at `<git-common-dir>/lmgrep/`.
19
+ * Git resolves that to the main checkout's `.git` even from a linked worktree,
20
+ * so every worktree of a repository agrees on one index by construction rather
21
+ * than by a shared registry that could disagree with reality. It also means
22
+ * the index is found by `du`, deleted by `rm -rf`, and gone when the clone is
23
+ * — which is what stops orphaned databases from accumulating somewhere the
24
+ * user never looks. Git never walks its own directory, so nothing here is ever
25
+ * committed or indexed.
26
+ *
27
+ * **Each embedding model gets its own database.** Vectors from different
28
+ * models are not comparable, so pointing lmgrep at a new model used to mean
29
+ * discarding the index or searching it with embeddings that quietly meant
30
+ * nothing. Keyed by model, switching is just a different subdirectory, and
31
+ * switching back finds the old index intact.
32
+ *
33
+ * **Everything else falls back to the state directory**: projects outside git
34
+ * have no repository to live in, and `--database <name>` is by definition not
35
+ * tied to one.
36
+ */
37
+ export declare class ProjectLocator {
38
+ private readonly git;
39
+ private readonly state;
40
+ /** The configured embedding model, which partitions the databases. */
41
+ private readonly model;
42
+ /** Configured output width, when the model has a configurable one. */
43
+ private readonly dimensions?;
44
+ /** Subdirectory of the git common directory holding every model's index. */
45
+ private static readonly REPOSITORY_SUBDIRECTORY;
46
+ constructor(git: GitPort, state: StateDirectoryPort,
47
+ /** The configured embedding model, which partitions the databases. */
48
+ model: ModelIdentity,
49
+ /** Configured output width, when the model has a configurable one. */
50
+ dimensions?: number | undefined);
51
+ /**
52
+ * Identify the project containing `cwd`.
53
+ *
54
+ * A git repo is identified by its origin URL when it has one, so every
55
+ * worktree and clone maps to a single identity; a remoteless repo falls
56
+ * back to its root path, and a plain directory to its own absolute path.
57
+ */
58
+ resolveProject(cwd: string): Project;
59
+ /** The directory holding every model's index for the project at `cwd`. */
60
+ indexHomeFor(cwd: string): string;
61
+ /** Database directory for the project containing `cwd`. */
62
+ databasePathFor(cwd: string): string;
63
+ /**
64
+ * The working tree a repository index belongs to, for display and for the
65
+ * registry.
66
+ *
67
+ * Worktrees share one database, so the toplevel of whichever worktree
68
+ * happened to run the index would name an arbitrary one of them. The main
69
+ * checkout — the parent of the common directory — is the stable answer.
70
+ */
71
+ projectRootFor(cwd: string): string;
72
+ /** Directory name the configured model's embeddings are stored under. */
73
+ modelSlug(): string;
74
+ /**
75
+ * Where an index built with `model` belongs.
76
+ *
77
+ * Needed when adopting a database written by an older layout, which knows
78
+ * which model built it but not which slot the current rules would put it
79
+ * in. It must go through here rather than deriving a slug independently:
80
+ * the width only counts when it was *configured*, since an index records
81
+ * the width it observed and that is the model's native size whenever
82
+ * nothing was requested. Computing the slug from the recorded width
83
+ * instead produced a directory the locator would never look in — an
84
+ * adopted index that was silently invisible.
85
+ */
86
+ databasePathForModel(cwd: string, model: ModelIdentity): string;
87
+ /**
88
+ * Decide which database a command targets.
89
+ *
90
+ * With no override this is the repository's index for the configured
91
+ * model. An override containing a separator is taken literally — it is an
92
+ * exact address, and appending anything to it would make it impossible to
93
+ * point at a database that already exists. A bare name is an identity
94
+ * instead, so it is model-scoped like any other.
95
+ *
96
+ * Either way the result is flat and branch-agnostic: indexing and search
97
+ * both use the default branch, so switching git branches never hides
98
+ * results in a database the user asked for explicitly. `cwd` still drives
99
+ * file scanning; only the database identity changes.
100
+ */
101
+ resolveDatabase(cwd: string, database?: string): DatabaseLocation;
102
+ /**
103
+ * Find the indexed project root covering `cwd` and the prefix from it.
104
+ *
105
+ * For a git repo the root is the toplevel. Outside git, walks up looking
106
+ * for an ancestor that already has an index, so running from a
107
+ * subdirectory of an indexed tree still finds it.
108
+ */
109
+ findIndexedAncestor(cwd: string): IndexedAncestor | undefined;
110
+ /** A `--database` override is a path when it carries a separator. */
111
+ private isPathLike;
112
+ }