lmgrep 0.1.18 → 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 (408) 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 +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 +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 -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/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/{lib/native-tuning.js → infrastructure/lancedb/NativeTuning.js} +1 -1
  265. package/dist/infrastructure/lancedb/NativeTuning.js.map +1 -0
  266. package/dist/infrastructure/lancedb/RowReplication.d.ts +27 -0
  267. package/dist/infrastructure/lancedb/RowReplication.js +82 -0
  268. package/dist/infrastructure/lancedb/RowReplication.js.map +1 -0
  269. package/dist/infrastructure/lancedb/VectorIndexPolicy.d.ts +60 -0
  270. package/dist/infrastructure/lancedb/VectorIndexPolicy.js +72 -0
  271. package/dist/infrastructure/lancedb/VectorIndexPolicy.js.map +1 -0
  272. package/dist/infrastructure/p2p/IndexShare.d.ts +45 -0
  273. package/dist/infrastructure/p2p/IndexShare.js +160 -0
  274. package/dist/infrastructure/p2p/IndexShare.js.map +1 -0
  275. package/dist/infrastructure/p2p/PeerSwarm.d.ts +16 -0
  276. package/dist/infrastructure/p2p/PeerSwarm.js +41 -0
  277. package/dist/infrastructure/p2p/PeerSwarm.js.map +1 -0
  278. package/dist/infrastructure/p2p/SecureChannel.d.ts +60 -0
  279. package/dist/infrastructure/p2p/SecureChannel.js +71 -0
  280. package/dist/infrastructure/p2p/SecureChannel.js.map +1 -0
  281. package/dist/infrastructure/p2p/ShareCode.d.ts +25 -0
  282. package/dist/infrastructure/p2p/ShareCode.js +304 -0
  283. package/dist/infrastructure/p2p/ShareCode.js.map +1 -0
  284. package/dist/infrastructure/process/ProcessRegistry.d.ts +50 -0
  285. package/dist/infrastructure/process/ProcessRegistry.js +109 -0
  286. package/dist/infrastructure/process/ProcessRegistry.js.map +1 -0
  287. package/dist/infrastructure/treesitter/ChunkContextBuilder.d.ts +45 -0
  288. package/dist/infrastructure/treesitter/ChunkContextBuilder.js +159 -0
  289. package/dist/infrastructure/treesitter/ChunkContextBuilder.js.map +1 -0
  290. package/dist/infrastructure/treesitter/LanguageCatalog.d.ts +30 -0
  291. package/dist/{lib/chunker/languages.js → infrastructure/treesitter/LanguageCatalog.js} +34 -29
  292. package/dist/infrastructure/treesitter/LanguageCatalog.js.map +1 -0
  293. package/dist/infrastructure/treesitter/SlidingWindowChunker.d.ts +15 -0
  294. package/dist/infrastructure/treesitter/SlidingWindowChunker.js +42 -0
  295. package/dist/infrastructure/treesitter/SlidingWindowChunker.js.map +1 -0
  296. package/dist/infrastructure/treesitter/TreeSitterChunker.d.ts +42 -0
  297. package/dist/infrastructure/treesitter/TreeSitterChunker.js +163 -0
  298. package/dist/infrastructure/treesitter/TreeSitterChunker.js.map +1 -0
  299. package/dist/mcp.d.ts +1 -1
  300. package/dist/mcp.js +14 -72
  301. package/dist/mcp.js.map +1 -1
  302. package/dist/presentation/cli/Cli.d.ts +31 -0
  303. package/dist/presentation/cli/Cli.js +120 -0
  304. package/dist/presentation/cli/Cli.js.map +1 -0
  305. package/dist/presentation/cli/CliOptions.d.ts +18 -0
  306. package/dist/presentation/cli/CliOptions.js +25 -0
  307. package/dist/presentation/cli/CliOptions.js.map +1 -0
  308. package/dist/presentation/cli/CommandContext.d.ts +50 -0
  309. package/dist/presentation/cli/CommandContext.js +88 -0
  310. package/dist/presentation/cli/CommandContext.js.map +1 -0
  311. package/dist/presentation/cli/ConfigTemplate.d.ts +31 -0
  312. package/dist/presentation/cli/ConfigTemplate.js +83 -0
  313. package/dist/presentation/cli/ConfigTemplate.js.map +1 -0
  314. package/dist/presentation/cli/Renderer.d.ts +90 -0
  315. package/dist/presentation/cli/Renderer.js +290 -0
  316. package/dist/presentation/cli/Renderer.js.map +1 -0
  317. package/dist/presentation/cli/commands/AskCommand.d.ts +14 -0
  318. package/dist/presentation/cli/commands/AskCommand.js +48 -0
  319. package/dist/presentation/cli/commands/AskCommand.js.map +1 -0
  320. package/dist/presentation/cli/commands/CompletionsCommand.d.ts +18 -0
  321. package/dist/presentation/cli/commands/CompletionsCommand.js +96 -0
  322. package/dist/presentation/cli/commands/CompletionsCommand.js.map +1 -0
  323. package/dist/presentation/cli/commands/ConfigCommands.d.ts +55 -0
  324. package/dist/presentation/cli/commands/ConfigCommands.js +204 -0
  325. package/dist/presentation/cli/commands/ConfigCommands.js.map +1 -0
  326. package/dist/presentation/cli/commands/IndexCommand.d.ts +18 -0
  327. package/dist/presentation/cli/commands/IndexCommand.js +54 -0
  328. package/dist/presentation/cli/commands/IndexCommand.js.map +1 -0
  329. package/dist/presentation/cli/commands/ProjectsCommand.d.ts +48 -0
  330. package/dist/presentation/cli/commands/ProjectsCommand.js +240 -0
  331. package/dist/presentation/cli/commands/ProjectsCommand.js.map +1 -0
  332. package/dist/presentation/cli/commands/SearchCommand.d.ts +19 -0
  333. package/dist/presentation/cli/commands/SearchCommand.js +55 -0
  334. package/dist/presentation/cli/commands/SearchCommand.js.map +1 -0
  335. package/dist/presentation/cli/commands/ServerCommands.d.ts +13 -0
  336. package/dist/presentation/cli/commands/ServerCommands.js +40 -0
  337. package/dist/presentation/cli/commands/ServerCommands.js.map +1 -0
  338. package/dist/presentation/cli/commands/ShareCommands.d.ts +22 -0
  339. package/dist/presentation/cli/commands/ShareCommands.js +134 -0
  340. package/dist/presentation/cli/commands/ShareCommands.js.map +1 -0
  341. package/dist/presentation/cli/commands/StatusCommand.d.ts +15 -0
  342. package/dist/presentation/cli/commands/StatusCommand.js +53 -0
  343. package/dist/presentation/cli/commands/StatusCommand.js.map +1 -0
  344. package/dist/presentation/mcp/HitFormatter.d.ts +17 -0
  345. package/dist/presentation/mcp/HitFormatter.js +42 -0
  346. package/dist/presentation/mcp/HitFormatter.js.map +1 -0
  347. package/dist/presentation/mcp/IndexWatchController.d.ts +17 -0
  348. package/dist/presentation/mcp/IndexWatchController.js +31 -0
  349. package/dist/presentation/mcp/IndexWatchController.js.map +1 -0
  350. package/dist/presentation/mcp/LmgrepCore.d.ts +66 -0
  351. package/dist/presentation/mcp/LmgrepCore.js +178 -0
  352. package/dist/presentation/mcp/LmgrepCore.js.map +1 -0
  353. package/dist/presentation/mcp/McpServer.d.ts +18 -0
  354. package/dist/presentation/mcp/McpServer.js +63 -0
  355. package/dist/presentation/mcp/McpServer.js.map +1 -0
  356. package/dist/presentation/mcp/ToolDescriptions.d.ts +40 -0
  357. package/dist/presentation/mcp/ToolDescriptions.js +85 -0
  358. package/dist/presentation/mcp/ToolDescriptions.js.map +1 -0
  359. package/package.json +84 -89
  360. package/dist/lib/build.d.ts +0 -21
  361. package/dist/lib/build.js +0 -374
  362. package/dist/lib/build.js.map +0 -1
  363. package/dist/lib/chunker/context.d.ts +0 -21
  364. package/dist/lib/chunker/context.js +0 -131
  365. package/dist/lib/chunker/context.js.map +0 -1
  366. package/dist/lib/chunker/index.d.ts +0 -7
  367. package/dist/lib/chunker/index.js +0 -209
  368. package/dist/lib/chunker/index.js.map +0 -1
  369. package/dist/lib/chunker/languages.d.ts +0 -15
  370. package/dist/lib/chunker/languages.js.map +0 -1
  371. package/dist/lib/config.d.ts +0 -12
  372. package/dist/lib/config.js +0 -83
  373. package/dist/lib/config.js.map +0 -1
  374. package/dist/lib/embedder.d.ts +0 -65
  375. package/dist/lib/embedder.js +0 -236
  376. package/dist/lib/embedder.js.map +0 -1
  377. package/dist/lib/facet-session.d.ts +0 -44
  378. package/dist/lib/facet-session.js +0 -125
  379. package/dist/lib/facet-session.js.map +0 -1
  380. package/dist/lib/native-tuning.js.map +0 -1
  381. package/dist/lib/p2p.d.ts +0 -32
  382. package/dist/lib/p2p.js +0 -281
  383. package/dist/lib/p2p.js.map +0 -1
  384. package/dist/lib/providers.d.ts +0 -1
  385. package/dist/lib/providers.js +0 -41
  386. package/dist/lib/providers.js.map +0 -1
  387. package/dist/lib/repair.d.ts +0 -10
  388. package/dist/lib/repair.js +0 -57
  389. package/dist/lib/repair.js.map +0 -1
  390. package/dist/lib/scanner.d.ts +0 -34
  391. package/dist/lib/scanner.js +0 -242
  392. package/dist/lib/scanner.js.map +0 -1
  393. package/dist/lib/search-tool.d.ts +0 -55
  394. package/dist/lib/search-tool.js +0 -319
  395. package/dist/lib/search-tool.js.map +0 -1
  396. package/dist/lib/serve.d.ts +0 -11
  397. package/dist/lib/serve.js +0 -144
  398. package/dist/lib/serve.js.map +0 -1
  399. package/dist/lib/store.d.ts +0 -252
  400. package/dist/lib/store.js +0 -1216
  401. package/dist/lib/store.js.map +0 -1
  402. package/dist/lib/types.d.ts +0 -194
  403. package/dist/lib/types.js +0 -13
  404. package/dist/lib/types.js.map +0 -1
  405. package/dist/lib/vocab.d.ts +0 -20
  406. package/dist/lib/vocab.js +0 -275
  407. package/dist/lib/vocab.js.map +0 -1
  408. /package/dist/{lib/native-tuning.d.ts → infrastructure/lancedb/NativeTuning.d.ts} +0 -0
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Tuning for the LanceDB vector index. The numbers here were measured on a
3
+ * 43k-chunk / 3584-dimension index; the comments record what they bought so a
4
+ * later change can tell a tuned value from an arbitrary one.
5
+ */
6
+ export const VectorIndexPolicy = {
7
+ /**
8
+ * Below this row count a brute-force scan is cheap enough that training an
9
+ * index costs more than it saves, and IVF-PQ has too few vectors to cluster
10
+ * well.
11
+ */
12
+ MIN_ROWS_FOR_ANN: 5_000,
13
+ /**
14
+ * Re-absorb new rows into the index once the unindexed tail passes this
15
+ * share of the indexed body. Rows outside the index are searched by flat
16
+ * scan, so the tail is exactly what needs bounding.
17
+ */
18
+ UNINDEXED_REINDEX_RATIO: 0.2,
19
+ /** ...but always tolerate a small tail, so a 3-chunk edit never retrains. */
20
+ UNINDEXED_REINDEX_FLOOR: 2_000,
21
+ /**
22
+ * Vector searches run without an explicit distance type, which LanceDB
23
+ * resolves to L2. The index has its own default, so it is pinned: an index
24
+ * built on a different metric would silently reorder every result.
25
+ */
26
+ DISTANCE_TYPE: "l2",
27
+ /**
28
+ * IVF-PQ stores compressed vectors, so its raw distances approximate the
29
+ * real ones. `refineFactor` makes LanceDB pull the uncompressed vectors for
30
+ * the top `limit * factor` candidates and re-score them exactly.
31
+ *
32
+ * It is not optional. Measured mean recall@20 against an exact scan:
33
+ *
34
+ * off -> 53% 1 -> 75% 3 -> 86% 10 -> 91% 20 -> 94% 50 -> 94%
35
+ *
36
+ * and without it `_distance` is wrong by ~0.07, which matters because score
37
+ * is derived from it and users filter on `--min-score`. With refinement the
38
+ * scores match an exact scan to the digit.
39
+ *
40
+ * 20 sits at the knee: ~94% recall at ~11ms/query versus ~115ms for an
41
+ * exact scan. Beyond it recall flattens (the probed partitions run out of
42
+ * candidates) while latency keeps climbing. The refined set is bounded by
43
+ * the query limit, not by table size, so this costs a fixed few MB.
44
+ *
45
+ * Harmless on tables with no index: a flat scan already computes exact
46
+ * distances and returns identical rows.
47
+ */
48
+ REFINE_FACTOR: 20,
49
+ };
50
+ /**
51
+ * Columns a search reads off a result row.
52
+ *
53
+ * Selecting explicitly keeps the embedding out of the result set — without it
54
+ * LanceDB ships every over-fetched row's full vector back into JS for nothing.
55
+ *
56
+ * `_distance` is listed on purpose: LanceDB currently auto-projects it into any
57
+ * scoring query but warns that it will stop, so naming it pins the behaviour
58
+ * rather than relying on a deprecated default.
59
+ */
60
+ export const SEARCH_COLUMNS = [
61
+ "id",
62
+ "filePath",
63
+ "startLine",
64
+ "endLine",
65
+ "type",
66
+ "name",
67
+ "content",
68
+ "context",
69
+ "fileHash",
70
+ "_distance",
71
+ ];
72
+ //# sourceMappingURL=VectorIndexPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VectorIndexPolicy.js","sourceRoot":"","sources":["../../../src/infrastructure/lancedb/VectorIndexPolicy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC;;;;OAIG;IACH,gBAAgB,EAAE,KAAK;IAEvB;;;;OAIG;IACH,uBAAuB,EAAE,GAAG;IAE5B,6EAA6E;IAC7E,uBAAuB,EAAE,KAAK;IAE9B;;;;OAIG;IACH,aAAa,EAAE,IAAI;IAEnB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,aAAa,EAAE,EAAE;CACR,CAAC;AAEX;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,IAAI;IACJ,UAAU;IACV,WAAW;IACX,SAAS;IACT,MAAM;IACN,MAAM;IACN,SAAS;IACT,SAAS;IACT,UAAU;IACV,WAAW;CACF,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { IndexMetadata } from "../../domain/project/IndexMetadata.js";
2
+ import type { RowReplication } from "../lancedb/RowReplication.js";
3
+ import { ShareCode } from "./ShareCode.js";
4
+ export interface ShareProgress {
5
+ onProgress?: (done: number, total: number) => void;
6
+ }
7
+ export interface ReceiveOptions extends ShareProgress {
8
+ onMeta?: (meta: {
9
+ model?: string;
10
+ dimensions?: number;
11
+ chunkCount: number;
12
+ remote?: string;
13
+ }) => void;
14
+ onWarning?: (message: string) => void;
15
+ }
16
+ export interface ReceiveResult {
17
+ chunks: number;
18
+ files: number;
19
+ }
20
+ /**
21
+ * Sends and receives a whole index between two machines.
22
+ *
23
+ * The transfer copies rows verbatim, embeddings included: re-embedding a large
24
+ * repository is the expensive thing, and avoiding it is the entire reason to
25
+ * share. That makes model compatibility the receiver's responsibility to check
26
+ * — vectors from a different model are silently meaningless, so a mismatch is
27
+ * warned about explicitly.
28
+ */
29
+ export declare class IndexShare {
30
+ private readonly rows;
31
+ private static readonly BATCH_SIZE;
32
+ private static readonly PEER_TIMEOUT_MS;
33
+ constructor(rows: RowReplication);
34
+ /**
35
+ * Publish the index and return the code a peer needs. `done` resolves once
36
+ * a peer has taken the whole transfer.
37
+ */
38
+ send(metadata: IndexMetadata | undefined, options?: ShareProgress): Promise<{
39
+ code: string;
40
+ done: Promise<void>;
41
+ }>;
42
+ /** Connect to a sharer and write everything it sends into this database. */
43
+ receive(code: ShareCode, localMetadata: IndexMetadata | undefined, options?: ReceiveOptions): Promise<ReceiveResult>;
44
+ private warnOnModelMismatch;
45
+ }
@@ -0,0 +1,160 @@
1
+ import { ModelIdentity } from "../../domain/project/ModelIdentity.js";
2
+ import { PeerSwarm } from "./PeerSwarm.js";
3
+ import { SecureChannel, } from "./SecureChannel.js";
4
+ import { ShareCode } from "./ShareCode.js";
5
+ /**
6
+ * Sends and receives a whole index between two machines.
7
+ *
8
+ * The transfer copies rows verbatim, embeddings included: re-embedding a large
9
+ * repository is the expensive thing, and avoiding it is the entire reason to
10
+ * share. That makes model compatibility the receiver's responsibility to check
11
+ * — vectors from a different model are silently meaningless, so a mismatch is
12
+ * warned about explicitly.
13
+ */
14
+ export class IndexShare {
15
+ rows;
16
+ static BATCH_SIZE = 200;
17
+ static PEER_TIMEOUT_MS = 5 * 60 * 1000;
18
+ constructor(rows) {
19
+ this.rows = rows;
20
+ }
21
+ /**
22
+ * Publish the index and return the code a peer needs. `done` resolves once
23
+ * a peer has taken the whole transfer.
24
+ */
25
+ async send(metadata, options = {}) {
26
+ const swarm = await PeerSwarm.create();
27
+ const code = ShareCode.generate();
28
+ const channel = new SecureChannel(code.toEncryptionKey());
29
+ const chunkCount = await this.rows.chunkCount();
30
+ const done = new Promise((resolve, reject) => {
31
+ const timeout = setTimeout(() => {
32
+ void swarm.destroy();
33
+ reject(new Error("Timed out waiting for peer (5 minutes)."));
34
+ }, IndexShare.PEER_TIMEOUT_MS);
35
+ swarm.onConnection(async (socket) => {
36
+ clearTimeout(timeout);
37
+ try {
38
+ channel.send(socket, {
39
+ type: "meta",
40
+ model: metadata?.model,
41
+ dimensions: metadata?.dimensions,
42
+ chunkCount,
43
+ branch: metadata?.branch ?? "main",
44
+ remote: metadata?.remote,
45
+ });
46
+ // Wait for the receiver to accept before streaming — it may
47
+ // refuse on an incompatible model.
48
+ await channel.await(socket, "ready");
49
+ let sent = 0;
50
+ for await (const batch of this.rows.streamChunkRows(IndexShare.BATCH_SIZE)) {
51
+ channel.send(socket, { type: "chunks", batch });
52
+ sent += batch.length;
53
+ options.onProgress?.(sent, chunkCount);
54
+ }
55
+ const files = await this.rows.allManifestRows();
56
+ if (files.length > 0) {
57
+ channel.send(socket, { type: "files", batch: files });
58
+ }
59
+ channel.send(socket, { type: "done" });
60
+ // Wait for the ack so the socket is not torn down before
61
+ // the receiver has committed.
62
+ await channel.await(socket, "ack");
63
+ socket.end();
64
+ await swarm.destroy();
65
+ resolve();
66
+ }
67
+ catch (err) {
68
+ await swarm.destroy();
69
+ reject(err);
70
+ }
71
+ });
72
+ swarm.join(code.toTopic(), "server").catch(reject);
73
+ });
74
+ return { code: code.toString(), done };
75
+ }
76
+ /** Connect to a sharer and write everything it sends into this database. */
77
+ async receive(code, localMetadata, options = {}) {
78
+ const swarm = await PeerSwarm.create();
79
+ const channel = new SecureChannel(code.toEncryptionKey());
80
+ return new Promise((resolve, reject) => {
81
+ const timeout = setTimeout(() => {
82
+ void swarm.destroy();
83
+ reject(new Error("Timed out waiting for peer (5 minutes)."));
84
+ }, IndexShare.PEER_TIMEOUT_MS);
85
+ const fail = (err) => {
86
+ void swarm.destroy().then(() => reject(err));
87
+ };
88
+ swarm.onConnection((socket) => {
89
+ clearTimeout(timeout);
90
+ let expected = 0;
91
+ let chunks = 0;
92
+ let files = 0;
93
+ let accepted = false;
94
+ const handle = (message) => {
95
+ switch (message.type) {
96
+ case "meta": {
97
+ expected = message.chunkCount;
98
+ options.onMeta?.({
99
+ model: message.model,
100
+ dimensions: message.dimensions,
101
+ chunkCount: message.chunkCount,
102
+ remote: message.remote,
103
+ });
104
+ this.warnOnModelMismatch(localMetadata, message, options.onWarning);
105
+ channel.send(socket, { type: "ready" });
106
+ accepted = true;
107
+ break;
108
+ }
109
+ case "chunks": {
110
+ // Ignore anything arriving before the handshake.
111
+ if (!accepted)
112
+ break;
113
+ chunks += message.batch.length;
114
+ options.onProgress?.(chunks, expected);
115
+ this.rows.addChunkRows(message.batch).catch(fail);
116
+ break;
117
+ }
118
+ case "files": {
119
+ if (!accepted)
120
+ break;
121
+ files += message.batch.length;
122
+ this.rows.addManifestRows(message.batch).catch(fail);
123
+ break;
124
+ }
125
+ case "done": {
126
+ channel.send(socket, { type: "ack" });
127
+ void swarm.destroy().then(() => resolve({ chunks, files }));
128
+ break;
129
+ }
130
+ }
131
+ };
132
+ const read = channel.reader((message) => {
133
+ try {
134
+ handle(message);
135
+ }
136
+ catch (err) {
137
+ fail(new Error(`Protocol error: ${err}`));
138
+ }
139
+ });
140
+ socket.on("data", read);
141
+ socket.on("error", fail);
142
+ });
143
+ swarm.join(code.toTopic(), "client").catch(reject);
144
+ });
145
+ }
146
+ warnOnModelMismatch(local, remote, onWarning) {
147
+ if (!local?.model || !remote.model)
148
+ return;
149
+ const localFamily = ModelIdentity.of(local.model).family;
150
+ const remoteFamily = ModelIdentity.of(remote.model).family;
151
+ if (localFamily === remoteFamily &&
152
+ local.dimensions === remote.dimensions) {
153
+ return;
154
+ }
155
+ onWarning?.(`Warning: source uses "${remote.model}" (${remote.dimensions} dims) ` +
156
+ `but local index uses "${local.model}" (${local.dimensions} dims). ` +
157
+ "Imported vectors may not be compatible.");
158
+ }
159
+ }
160
+ //# sourceMappingURL=IndexShare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndexShare.js","sourceRoot":"","sources":["../../../src/infrastructure/p2p/IndexShare.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAEN,aAAa,GAEb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAqB3C;;;;;;;;GAQG;AACH,MAAM,OAAO,UAAU;IAIO;IAHrB,MAAM,CAAU,UAAU,GAAG,GAAG,CAAC;IACjC,MAAM,CAAU,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IAExD,YAA6B,IAAoB;QAApB,SAAI,GAAJ,IAAI,CAAgB;IAAG,CAAC;IAErD;;;OAGG;IACH,KAAK,CAAC,IAAI,CACT,QAAmC,EACnC,UAAyB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C;oBAAC,OAAO,GAAG,EAAE,CAAC;wBACd,IAAI,CAAC,IAAI,KAAK,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC,CAAC;oBAC3C,CAAC;gBACF,CAAC,CAAC,CAAC;gBACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBACxB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,mBAAmB,CAC1B,KAAgC,EAChC,MAA+C,EAC/C,SAAqC;QAErC,IAAI,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK;YAAE,OAAO;QAC3C,MAAM,WAAW,GAAG,aAAa,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;QACzD,MAAM,YAAY,GAAG,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;QAC3D,IACC,WAAW,KAAK,YAAY;YAC5B,KAAK,CAAC,UAAU,KAAK,MAAM,CAAC,UAAU,EACrC,CAAC;YACF,OAAO;QACR,CAAC;QACD,SAAS,EAAE,CACV,yBAAyB,MAAM,CAAC,KAAK,MAAM,MAAM,CAAC,UAAU,SAAS;YACpE,yBAAyB,KAAK,CAAC,KAAK,MAAM,KAAK,CAAC,UAAU,UAAU;YACpE,yCAAyC,CAC1C,CAAC;IACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { DuplexSocket } from "./SecureChannel.js";
2
+ /**
3
+ * Peer discovery over Hyperswarm.
4
+ *
5
+ * Imported lazily and treated as optional: sharing is a side feature, and its
6
+ * native dependency should not be required to run a search.
7
+ */
8
+ export declare class PeerSwarm {
9
+ private readonly swarm;
10
+ private constructor();
11
+ static create(): Promise<PeerSwarm>;
12
+ onConnection(handler: (socket: DuplexSocket) => void): void;
13
+ /** Announce as a server (sharer) or dial as a client (receiver). */
14
+ join(topic: Buffer, role: "server" | "client"): Promise<void>;
15
+ destroy(): Promise<void>;
16
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Peer discovery over Hyperswarm.
3
+ *
4
+ * Imported lazily and treated as optional: sharing is a side feature, and its
5
+ * native dependency should not be required to run a search.
6
+ */
7
+ export class PeerSwarm {
8
+ swarm;
9
+ constructor(swarm) {
10
+ this.swarm = swarm;
11
+ }
12
+ static async create() {
13
+ let module;
14
+ try {
15
+ // @ts-expect-error -- no type declarations for hyperswarm
16
+ module = await import("hyperswarm");
17
+ }
18
+ catch {
19
+ throw new Error("hyperswarm is not installed. Run: pnpm add hyperswarm");
20
+ }
21
+ const Constructor = (module.default ??
22
+ module);
23
+ return new PeerSwarm(new Constructor());
24
+ }
25
+ onConnection(handler) {
26
+ this.swarm.on("connection", handler);
27
+ }
28
+ /** Announce as a server (sharer) or dial as a client (receiver). */
29
+ async join(topic, role) {
30
+ await this.swarm
31
+ .join(topic, {
32
+ server: role === "server",
33
+ client: role === "client",
34
+ })
35
+ .flushed();
36
+ }
37
+ async destroy() {
38
+ await this.swarm.destroy().catch(() => { });
39
+ }
40
+ }
41
+ //# sourceMappingURL=PeerSwarm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PeerSwarm.js","sourceRoot":"","sources":["../../../src/infrastructure/p2p/PeerSwarm.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IACgB;IAArC,YAAqC,KAAyB;QAAzB,UAAK,GAAL,KAAK,CAAoB;IAAG,CAAC;IAElE,MAAM,CAAC,KAAK,CAAC,MAAM;QAClB,IAAI,MAAkD,CAAC;QACvD,IAAI,CAAC;YACJ,0DAA0D;YAC1D,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;QACrC,CAAC;QAAC,MAAM,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;QAC1E,CAAC;QACD,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,OAAO;YAClC,MAAM,CAAiC,CAAC;QACzC,OAAO,IAAI,SAAS,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,YAAY,CAAC,OAAuC;QACnD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,oEAAoE;IACpE,KAAK,CAAC,IAAI,CAAC,KAAa,EAAE,IAAyB;QAClD,MAAM,IAAI,CAAC,KAAK;aACd,IAAI,CAAC,KAAK,EAAE;YACZ,MAAM,EAAE,IAAI,KAAK,QAAQ;YACzB,MAAM,EAAE,IAAI,KAAK,QAAQ;SACzB,CAAC;aACD,OAAO,EAAE,CAAC;IACb,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;CACD"}
@@ -0,0 +1,60 @@
1
+ /** Messages exchanged during a share. */
2
+ export type ShareMessage = {
3
+ type: "meta";
4
+ model?: string;
5
+ dimensions?: number;
6
+ chunkCount: number;
7
+ branch: string;
8
+ remote?: string;
9
+ } | {
10
+ type: "ready";
11
+ } | {
12
+ type: "chunks";
13
+ batch: Record<string, unknown>[];
14
+ } | {
15
+ type: "files";
16
+ batch: Array<{
17
+ filePath: string;
18
+ fileHash: string;
19
+ branch: string;
20
+ }>;
21
+ } | {
22
+ type: "done";
23
+ } | {
24
+ type: "ack";
25
+ };
26
+ /** The transport a share runs over. */
27
+ export interface DuplexSocket {
28
+ write(data: Buffer): boolean;
29
+ on(event: "data", cb: (chunk: Buffer) => void): void;
30
+ on(event: "end" | "close" | "error", cb: (err?: Error) => void): void;
31
+ end(): void;
32
+ destroy(): void;
33
+ }
34
+ /**
35
+ * Authenticated encryption and message framing over a raw peer socket.
36
+ *
37
+ * AES-256-GCM, so a tampered payload fails to decrypt rather than being parsed
38
+ * — a peer discovered over a public DHT is not trusted. Frames carry an
39
+ * explicit length prefix because a stream socket splits and merges writes
40
+ * arbitrarily, and JSON alone gives no way to find a message boundary.
41
+ */
42
+ export declare class SecureChannel {
43
+ private readonly key;
44
+ private static readonly IV_BYTES;
45
+ private static readonly TAG_BYTES;
46
+ private static readonly LENGTH_PREFIX_BYTES;
47
+ constructor(key: Buffer);
48
+ send(socket: {
49
+ write(data: Buffer): boolean;
50
+ }, message: ShareMessage): void;
51
+ /**
52
+ * A stateful reader: feed it raw socket chunks, and it emits whole
53
+ * messages as their frames complete.
54
+ */
55
+ reader(onMessage: (message: ShareMessage) => void): (chunk: Buffer) => void;
56
+ /** Resolve once a message of the expected type arrives. */
57
+ await(socket: DuplexSocket, expected: ShareMessage["type"]): Promise<ShareMessage>;
58
+ private encrypt;
59
+ private decrypt;
60
+ }
@@ -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
+ //# sourceM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AG,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
+ }