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,71 @@
1
+ import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
2
+ /**
3
+ * Authenticated encryption and message framing over a raw peer socket.
4
+ *
5
+ * AES-256-GCM, so a tampered payload fails to decrypt rather than being parsed
6
+ * — a peer discovered over a public DHT is not trusted. Frames carry an
7
+ * explicit length prefix because a stream socket splits and merges writes
8
+ * arbitrarily, and JSON alone gives no way to find a message boundary.
9
+ */
10
+ export class SecureChannel {
11
+ key;
12
+ static IV_BYTES = 12;
13
+ static TAG_BYTES = 16;
14
+ static LENGTH_PREFIX_BYTES = 4;
15
+ constructor(key) {
16
+ this.key = key;
17
+ }
18
+ send(socket, message) {
19
+ const encrypted = this.encrypt(Buffer.from(JSON.stringify(message)));
20
+ const frame = Buffer.alloc(SecureChannel.LENGTH_PREFIX_BYTES + encrypted.length);
21
+ frame.writeUInt32BE(encrypted.length, 0);
22
+ encrypted.copy(frame, SecureChannel.LENGTH_PREFIX_BYTES);
23
+ socket.write(frame);
24
+ }
25
+ /**
26
+ * A stateful reader: feed it raw socket chunks, and it emits whole
27
+ * messages as their frames complete.
28
+ */
29
+ reader(onMessage) {
30
+ let buffered = Buffer.alloc(0);
31
+ return (chunk) => {
32
+ buffered = Buffer.concat([buffered, chunk]);
33
+ while (buffered.length >= SecureChannel.LENGTH_PREFIX_BYTES) {
34
+ const length = buffered.readUInt32BE(0);
35
+ if (buffered.length < SecureChannel.LENGTH_PREFIX_BYTES + length) {
36
+ break;
37
+ }
38
+ const frame = buffered.subarray(SecureChannel.LENGTH_PREFIX_BYTES, SecureChannel.LENGTH_PREFIX_BYTES + length);
39
+ buffered = buffered.subarray(SecureChannel.LENGTH_PREFIX_BYTES + length);
40
+ onMessage(JSON.parse(this.decrypt(frame).toString()));
41
+ }
42
+ };
43
+ }
44
+ /** Resolve once a message of the expected type arrives. */
45
+ await(socket, expected) {
46
+ return new Promise((resolve, reject) => {
47
+ const read = this.reader((message) => {
48
+ if (message.type === expected)
49
+ resolve(message);
50
+ });
51
+ socket.on("data", read);
52
+ socket.on("error", reject);
53
+ socket.on("close", () => reject(new Error("Connection closed")));
54
+ });
55
+ }
56
+ encrypt(plaintext) {
57
+ const iv = randomBytes(SecureChannel.IV_BYTES);
58
+ const cipher = createCipheriv("aes-256-gcm", this.key, iv);
59
+ const body = Buffer.concat([cipher.update(plaintext), cipher.final()]);
60
+ return Buffer.concat([iv, cipher.getAuthTag(), body]);
61
+ }
62
+ decrypt(data) {
63
+ const iv = data.subarray(0, SecureChannel.IV_BYTES);
64
+ const tag = data.subarray(SecureChannel.IV_BYTES, SecureChannel.IV_BYTES + SecureChannel.TAG_BYTES);
65
+ const body = data.subarray(SecureChannel.IV_BYTES + SecureChannel.TAG_BYTES);
66
+ const decipher = createDecipheriv("aes-256-gcm", this.key, iv);
67
+ decipher.setAuthTag(tag);
68
+ return Buffer.concat([decipher.update(body), decipher.final()]);
69
+ }
70
+ }
71
+ //# sourceMappingURL=SecureChannel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SecureChannel.js","sourceRoot":"","sources":["../../../src/infrastructure/p2p/SecureChannel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA8B5E;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IAKI;IAJrB,MAAM,CAAU,QAAQ,GAAG,EAAE,CAAC;IAC9B,MAAM,CAAU,SAAS,GAAG,EAAE,CAAC;IAC/B,MAAM,CAAU,mBAAmB,GAAG,CAAC,CAAC;IAEhD,YAA6B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAE5C,IAAI,CAAC,MAAwC,EAAE,OAAqB;QACnE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CACzB,aAAa,CAAC,mBAAmB,GAAG,SAAS,CAAC,MAAM,CACpD,CAAC;QACF,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACzC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;QACzD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,SAA0C;QAChD,IAAI,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,OAAO,CAAC,KAAa,EAAE,EAAE;YACxB,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAC5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AAE,GAAG,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,cAAc,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC3D,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACvE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;IAEO,OAAO,CAAC,IAAY;QAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;QACpD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CACxB,aAAa,CAAC,QAAQ,EACtB,aAAa,CAAC,QAAQ,GAAG,aAAa,CAAC,SAAS,CAChD,CAAC;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CACzB,aAAa,CAAC,QAAQ,GAAG,aAAa,CAAC,SAAS,CAChD,CAAC;QACF,MAAM,QAAQ,GAAG,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC/D,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACzB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjE,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A human-transcribable one-time code that both names a rendezvous topic and
3
+ * derives the encryption key for a share.
4
+ *
5
+ * Three words plus hex: short enough to read aloud, with 40 bits of entropy in
6
+ * the suffix so a code cannot be guessed within its lifetime.
7
+ *
8
+ * Topic and key are derived from the code by *separate* HKDF labels. That
9
+ * separation is the point — peer discovery necessarily publishes the topic, and
10
+ * it must not leak anything about the key protecting the payload.
11
+ */
12
+ export declare class ShareCode {
13
+ readonly value: string;
14
+ private static readonly WORDS;
15
+ static readonly PATTERN: RegExp;
16
+ private constructor();
17
+ static generate(): ShareCode;
18
+ static parse(value: string): ShareCode | undefined;
19
+ static looksLikeCode(value: string): boolean;
20
+ toString(): string;
21
+ /** Rendezvous topic for peer discovery. Public by nature. */
22
+ toTopic(): Buffer;
23
+ /** AES-256 key for the payload. Never derivable from the topic. */
24
+ toEncryptionKey(): Buffer;
25
+ }
@@ -0,0 +1,304 @@
1
+ import { hkdfSync, randomBytes } from "node:crypto";
2
+ /**
3
+ * A human-transcribable one-time code that both names a rendezvous topic and
4
+ * derives the encryption key for a share.
5
+ *
6
+ * Three words plus hex: short enough to read aloud, with 40 bits of entropy in
7
+ * the suffix so a code cannot be guessed within its lifetime.
8
+ *
9
+ * Topic and key are derived from the code by *separate* HKDF labels. That
10
+ * separation is the point — peer discovery necessarily publishes the topic, and
11
+ * it must not leak anything about the key protecting the payload.
12
+ */
13
+ export class ShareCode {
14
+ value;
15
+ static WORDS = [
16
+ "acid",
17
+ "acme",
18
+ "aged",
19
+ "also",
20
+ "arch",
21
+ "area",
22
+ "army",
23
+ "away",
24
+ "back",
25
+ "bail",
26
+ "bake",
27
+ "band",
28
+ "bank",
29
+ "barn",
30
+ "base",
31
+ "bath",
32
+ "beam",
33
+ "bean",
34
+ "bear",
35
+ "beat",
36
+ "beef",
37
+ "beer",
38
+ "bell",
39
+ "belt",
40
+ "bend",
41
+ "bike",
42
+ "bird",
43
+ "bite",
44
+ "blow",
45
+ "blue",
46
+ "boat",
47
+ "body",
48
+ "bolt",
49
+ "bomb",
50
+ "bond",
51
+ "bone",
52
+ "book",
53
+ "boot",
54
+ "born",
55
+ "boss",
56
+ "bowl",
57
+ "bulk",
58
+ "bull",
59
+ "burn",
60
+ "cage",
61
+ "cake",
62
+ "calm",
63
+ "came",
64
+ "camp",
65
+ "cape",
66
+ "card",
67
+ "care",
68
+ "cart",
69
+ "case",
70
+ "cash",
71
+ "cast",
72
+ "cave",
73
+ "chef",
74
+ "chip",
75
+ "city",
76
+ "clan",
77
+ "clay",
78
+ "clip",
79
+ "club",
80
+ "clue",
81
+ "coal",
82
+ "coat",
83
+ "code",
84
+ "coil",
85
+ "coin",
86
+ "cold",
87
+ "come",
88
+ "cook",
89
+ "cool",
90
+ "cope",
91
+ "copy",
92
+ "cord",
93
+ "core",
94
+ "corn",
95
+ "cost",
96
+ "crew",
97
+ "crop",
98
+ "crow",
99
+ "cure",
100
+ "curl",
101
+ "cute",
102
+ "dame",
103
+ "damp",
104
+ "dare",
105
+ "dark",
106
+ "dash",
107
+ "data",
108
+ "dawn",
109
+ "deal",
110
+ "dean",
111
+ "deck",
112
+ "deep",
113
+ "deer",
114
+ "demo",
115
+ "desk",
116
+ "dial",
117
+ "dice",
118
+ "diet",
119
+ "dirt",
120
+ "disk",
121
+ "dock",
122
+ "door",
123
+ "dose",
124
+ "down",
125
+ "draw",
126
+ "drop",
127
+ "drum",
128
+ "dual",
129
+ "duck",
130
+ "dull",
131
+ "dump",
132
+ "dune",
133
+ "dust",
134
+ "duty",
135
+ "each",
136
+ "earl",
137
+ "earn",
138
+ "ease",
139
+ "east",
140
+ "edge",
141
+ "else",
142
+ "epic",
143
+ "even",
144
+ "ever",
145
+ "exam",
146
+ "exit",
147
+ "face",
148
+ "fact",
149
+ "fade",
150
+ "fail",
151
+ "fair",
152
+ "fall",
153
+ "fame",
154
+ "farm",
155
+ "fast",
156
+ "fate",
157
+ "fawn",
158
+ "feed",
159
+ "feel",
160
+ "file",
161
+ "film",
162
+ "find",
163
+ "fine",
164
+ "fire",
165
+ "firm",
166
+ "fish",
167
+ "flag",
168
+ "flat",
169
+ "fled",
170
+ "flip",
171
+ "flow",
172
+ "foam",
173
+ "fold",
174
+ "folk",
175
+ "fond",
176
+ "food",
177
+ "fool",
178
+ "fork",
179
+ "form",
180
+ "fort",
181
+ "foul",
182
+ "four",
183
+ "free",
184
+ "frog",
185
+ "fuel",
186
+ "full",
187
+ "fund",
188
+ "fury",
189
+ "fuse",
190
+ "gain",
191
+ "gale",
192
+ "game",
193
+ "gang",
194
+ "gate",
195
+ "gave",
196
+ "gaze",
197
+ "gear",
198
+ "gene",
199
+ "gift",
200
+ "glad",
201
+ "glow",
202
+ "glue",
203
+ "goat",
204
+ "gold",
205
+ "golf",
206
+ "gone",
207
+ "good",
208
+ "grab",
209
+ "gray",
210
+ "grid",
211
+ "grip",
212
+ "grow",
213
+ "gulf",
214
+ "guru",
215
+ "gust",
216
+ "hack",
217
+ "half",
218
+ "hall",
219
+ "halt",
220
+ "hand",
221
+ "hang",
222
+ "hare",
223
+ "harm",
224
+ "harp",
225
+ "hash",
226
+ "hate",
227
+ "haul",
228
+ "have",
229
+ "hawk",
230
+ "haze",
231
+ "head",
232
+ "heap",
233
+ "heat",
234
+ "held",
235
+ "helm",
236
+ "help",
237
+ "herb",
238
+ "herd",
239
+ "here",
240
+ "hero",
241
+ "hide",
242
+ "high",
243
+ "hike",
244
+ "hill",
245
+ "hilt",
246
+ "hint",
247
+ "hire",
248
+ "hold",
249
+ "hole",
250
+ "holy",
251
+ "home",
252
+ "hood",
253
+ "hook",
254
+ "hope",
255
+ "horn",
256
+ "host",
257
+ "hour",
258
+ "huge",
259
+ "hull",
260
+ "hung",
261
+ "hunt",
262
+ "hurt",
263
+ "icon",
264
+ "idea",
265
+ "inch",
266
+ "info",
267
+ "iron",
268
+ "isle",
269
+ "item",
270
+ "jack",
271
+ "jade",
272
+ ];
273
+ static PATTERN = /^lmgrep[a-z]+[0-9a-f]{10}$/;
274
+ constructor(value) {
275
+ this.value = value;
276
+ }
277
+ static generate() {
278
+ const bytes = randomBytes(16);
279
+ const words = [
280
+ ShareCode.WORDS[bytes[0]],
281
+ ShareCode.WORDS[bytes[1]],
282
+ ShareCode.WORDS[bytes[2]],
283
+ ].join("");
284
+ return new ShareCode(`lmgrep${words}${bytes.subarray(3, 8).toString("hex")}`);
285
+ }
286
+ static parse(value) {
287
+ return ShareCode.looksLikeCode(value) ? new ShareCode(value) : undefined;
288
+ }
289
+ static looksLikeCode(value) {
290
+ return ShareCode.PATTERN.test(value);
291
+ }
292
+ toString() {
293
+ return this.value;
294
+ }
295
+ /** Rendezvous topic for peer discovery. Public by nature. */
296
+ toTopic() {
297
+ return Buffer.from(hkdfSync("sha256", this.value, "lmgrep-topic", "topic", 32));
298
+ }
299
+ /** AES-256 key for the payload. Never derivable from the topic. */
300
+ toEncryptionKey() {
301
+ return Buffer.from(hkdfSync("sha256", this.value, "lmgrep-key", "encryption", 32));
302
+ }
303
+ }
304
+ //# sourceMappingURL=ShareCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShareCode.js","sourceRoot":"","sources":["../../../src/infrastructure/p2p/ShareCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,SAAS;IAsQQ;IArQrB,MAAM,CAAU,KAAK,GAAG;QAC/B,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAA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C9B,MAAM,KAAK,GAAG;YACb,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACzB,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACzB,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACX,OAAO,IAAI,SAAS,CACnB,SAAS,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CACvD,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAa;QACzB,OAAO,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1E,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,KAAa;QACjC,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,6DAA6D;IAC7D,OAAO;QACN,OAAO,MAAM,CAAC,IAAI,CACjB,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE,CAAC,CAC3D,CAAC;IACH,CAAC;IAED,mEAAmE;IACnE,eAAe;QACd,OAAO,MAAM,CAAC,IAAI,CACjB,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,CAAC,CAC9D,CAAC;IACH,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { StateDirectoryPort } from "../../domain/ports/StateDirectoryPort.js";
2
+ /** What kind of lmgrep invocation a process is. */
3
+ export type ProcessKind = "mcp" | "serve" | "cli";
4
+ /** A live lmgrep process holding a database's maintainer lock. */
5
+ export interface RunningProcess {
6
+ pid: number;
7
+ /** Process title from /proc/<pid>/comm (e.g. "lmgrep-mcp"). */
8
+ processName: string;
9
+ cmdline: string;
10
+ kind: ProcessKind;
11
+ /** Working tree this process watches. */
12
+ projectRoot?: string;
13
+ /** Database it holds. */
14
+ databasePath?: string;
15
+ /** Whether this process is watching the index for changes. */
16
+ watching: boolean;
17
+ }
18
+ /**
19
+ * Discovers which lmgrep processes are alive and what they hold.
20
+ *
21
+ * Maintainer lock files double as the registry: each records its owner's pid,
22
+ * worktree and database, so scanning them and testing liveness gives an
23
+ * accurate picture without any separate bookkeeping that could drift from
24
+ * reality.
25
+ */
26
+ export declare class ProcessRegistry {
27
+ private readonly state;
28
+ private static readonly LOCK_SUFFIX;
29
+ constructor(state: StateDirectoryPort);
30
+ discoverRunning(): RunningProcess[];
31
+ /**
32
+ * Lock files, from the locks directory and from the state root.
33
+ *
34
+ * The root is scanned too because a watcher started before locks moved is
35
+ * still running and still holds its database — reporting "no running
36
+ * processes" right after an upgrade would be wrong in exactly the moment
37
+ * someone is most likely to check.
38
+ */
39
+ private lockFiles;
40
+ private inspect;
41
+ /**
42
+ * What kind of process this is, from its title.
43
+ *
44
+ * The title is the only reliable signal: `process.title` rewrites the argv
45
+ * buffer, so /proc/<pid>/cmdline reads back as the title alone and carries
46
+ * no subcommand. The MCP entry point titles itself distinctly; anything
47
+ * else holding a maintainer lock reached it through `lmgrep serve`.
48
+ */
49
+ private classify;
50
+ }
@@ -0,0 +1,109 @@
1
+ import { readdirSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { PidFileLock } from "../fs/PidFileLock.js";
4
+ /**
5
+ * Discovers which lmgrep processes are alive and what they hold.
6
+ *
7
+ * Maintainer lock files double as the registry: each records its owner's pid,
8
+ * worktree and database, so scanning them and testing liveness gives an
9
+ * accurate picture without any separate bookkeeping that could drift from
10
+ * reality.
11
+ */
12
+ export class ProcessRegistry {
13
+ state;
14
+ static LOCK_SUFFIX = ".lock";
15
+ constructor(state) {
16
+ this.state = state;
17
+ }
18
+ discoverRunning() {
19
+ const results = [];
20
+ // One process can hold several databases; report it once.
21
+ const seen = new Set();
22
+ for (const path of this.lockFiles()) {
23
+ const owner = new PidFileLock(path).read();
24
+ if (owner === undefined)
25
+ continue;
26
+ if (!PidFileLock.isAlive(owner.pid) || seen.has(owner.pid))
27
+ continue;
28
+ seen.add(owner.pid);
29
+ const info = this.inspect(owner.pid);
30
+ if (!info)
31
+ continue;
32
+ results.push({
33
+ pid: owner.pid,
34
+ processName: info.name,
35
+ cmdline: info.cmdline,
36
+ kind: this.classify(info),
37
+ // The lock records the worktree its owner actually watches,
38
+ // which is what the user wants to see — several worktrees can
39
+ // share one database, so the database's own recorded root
40
+ // would name the wrong tree.
41
+ projectRoot: owner.root,
42
+ databasePath: owner.database,
43
+ // Every lock in this scan is a maintainer lock, and only a
44
+ // watcher ever takes one — so holding it *is* watching. This
45
+ // used to be inferred from the command line, which cannot
46
+ // work: setting process.title overwrites that buffer, so the
47
+ // subcommand a process was launched with is no longer there
48
+ // to match against.
49
+ watching: true,
50
+ });
51
+ }
52
+ return results;
53
+ }
54
+ /**
55
+ * Lock files, from the locks directory and from the state root.
56
+ *
57
+ * The root is scanned too because a watcher started before locks moved is
58
+ * still running and still holds its database — reporting "no running
59
+ * processes" right after an upgrade would be wrong in exactly the moment
60
+ * someone is most likely to check.
61
+ */
62
+ lockFiles() {
63
+ const out = [];
64
+ for (const directory of [this.state.locksDirectory(), this.state.root()]) {
65
+ let entries;
66
+ try {
67
+ entries = readdirSync(directory);
68
+ }
69
+ catch {
70
+ continue;
71
+ }
72
+ for (const entry of entries) {
73
+ if (entry.endsWith(ProcessRegistry.LOCK_SUFFIX)) {
74
+ out.push(join(directory, entry));
75
+ }
76
+ }
77
+ }
78
+ return out;
79
+ }
80
+ inspect(pid) {
81
+ try {
82
+ return {
83
+ name: readFileSync(`/proc/${pid}/comm`, "utf-8").trim(),
84
+ cmdline: readFileSync(`/proc/${pid}/cmdline`, "utf-8")
85
+ .replace(/\0/g, " ")
86
+ .trim(),
87
+ };
88
+ }
89
+ catch {
90
+ // No procfs (macOS) or the process exited mid-scan.
91
+ return undefined;
92
+ }
93
+ }
94
+ /**
95
+ * What kind of process this is, from its title.
96
+ *
97
+ * The title is the only reliable signal: `process.title` rewrites the argv
98
+ * buffer, so /proc/<pid>/cmdline reads back as the title alone and carries
99
+ * no subcommand. The MCP entry point titles itself distinctly; anything
100
+ * else holding a maintainer lock reached it through `lmgrep serve`.
101
+ */
102
+ classify(info) {
103
+ if (info.name === "lmgrep-mcp" || info.cmdline.includes("mcp")) {
104
+ return "mcp";
105
+ }
106
+ return "serve";
107
+ }
108
+ }
109
+ //# sourceMappingURL=ProcessRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcessRegistry.js","sourceRoot":"","sources":["../../../src/infrastructure/process/ProcessRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAoBnD;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IAGE;IAFrB,MAAM,CAAU,WAAW,GAAG,OAAO,CAAC;IAE9C,YAA6B,KAAyB;QAAzB,UAAK,GAAL,KAAK,CAAoB;IAAG,CAAC;IAE1D,eAAe;QACd,MAAM,OAAO,GAAqB,EAAE,CAAC;QACrC,0DAA0D;QAC1D,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAE/B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;YACrC,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YAC3C,IAAI,KAAK,KAAK,SAAS;gBAAE,SAAS;YAClC,I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7B,IAAI,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC;oBACjD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;gBAClC,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAEO,OAAO,CAAC,GAAW;QAC1B,IAAI,CAAC;YACJ,OAAO;gBACN,IAAI,EAAE,YAAY,CAAC,SAAS,GAAG,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE;gBACvD,OAAO,EAAE,YAAY,CAAC,SAAS,GAAG,UAAU,EAAE,OAAO,CAAC;qBACpD,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;qBACnB,IAAI,EAAE;aACR,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACR,oDAAoD;YACpD,OAAO,SAAS,CAAC;QAClB,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;IACK,QAAQ,CAAC,IAAuC;QACvD,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAChE,OAAO,KAAK,CAAC;QACd,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { Node } from "web-tree-sitter";
2
+ import type { LanguageConfig } from "./LanguageCatalog.js";
3
+ /** What kind of thing a chunk is, structurally. */
4
+ export type StructuralRole = "definition" | "orchestration" | "implementation";
5
+ /** One enclosing scope, e.g. `class Foo`. */
6
+ export interface ScopeEntry {
7
+ kind: string;
8
+ name: string;
9
+ }
10
+ /**
11
+ * Builds the context header prepended to a chunk before embedding.
12
+ *
13
+ * The header is what makes an isolated function retrievable: on its own,
14
+ * `async function handle(req)` shares little vocabulary with "how are webhooks
15
+ * authenticated", but stamped with its file, enclosing class and doc comment
16
+ * it does. Retrieval quality depends on this at least as much as on the text.
17
+ */
18
+ export declare class ChunkContextBuilder {
19
+ /** How far above a node to look for its doc comment. */
20
+ private static readonly MAX_COMMENT_LOOKBACK;
21
+ /** AST node type -> the word used for it in the header. */
22
+ private static readonly SCOPE_KINDS;
23
+ /** Node types that declare a shape rather than behaviour. */
24
+ private static readonly DEFINITION_TYPES;
25
+ /** Node types that wire things together rather than implement them. */
26
+ private static readonly ORCHESTRATION_TYPES;
27
+ /** The full header for one chunk. */
28
+ build(node: Node, filePath: string, source: string, language: LanguageConfig): string;
29
+ /** The minimal header for a file with no parsed structure. */
30
+ buildFileOnly(filePath: string): string;
31
+ /** Walk up from a node collecting the named scopes that enclose it. */
32
+ extractScope(node: Node, language: LanguageConfig): ScopeEntry[];
33
+ /**
34
+ * Collect the comment block or decorators immediately above a node.
35
+ *
36
+ * A blank line ends the block only once something has been collected, so a
37
+ * comment separated from its node by whitespace is still picked up, while
38
+ * unrelated code above it is not.
39
+ */
40
+ extractLeadingComment(node: Node, source: string): string | null;
41
+ classifyRole(node: Node): StructuralRole;
42
+ /** Comment syntax across every supported language, plus decorators. */
43
+ private looksLikeCommentOrDecorator;
44
+ private nodeName;
45
+ }