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.
- package/README.md +226 -63
- package/completions/_lmgrep +49 -40
- package/dist/application/Lmgrep.d.ts +107 -0
- package/dist/application/Lmgrep.js +99 -0
- package/dist/application/Lmgrep.js.map +1 -0
- package/dist/application/LmgrepFactory.d.ts +40 -0
- package/dist/application/LmgrepFactory.js +155 -0
- package/dist/application/LmgrepFactory.js.map +1 -0
- package/dist/application/indexing/BranchBootstrapper.d.ts +21 -0
- package/dist/application/indexing/BranchBootstrapper.js +52 -0
- package/dist/application/indexing/BranchBootstrapper.js.map +1 -0
- package/dist/application/indexing/BranchManifestSweeper.d.ts +17 -0
- package/dist/application/indexing/BranchManifestSweeper.js +35 -0
- package/dist/application/indexing/BranchManifestSweeper.js.map +1 -0
- package/dist/application/indexing/Duration.d.ts +9 -0
- package/dist/application/indexing/Duration.js +25 -0
- package/dist/application/indexing/Duration.js.map +1 -0
- package/dist/application/indexing/EmbeddingAbortError.d.ts +11 -0
- package/dist/application/indexing/EmbeddingAbortError.js +20 -0
- package/dist/application/indexing/EmbeddingAbortError.js.map +1 -0
- package/dist/application/indexing/EmbeddingPipeline.d.ts +59 -0
- package/dist/application/indexing/EmbeddingPipeline.js +140 -0
- package/dist/application/indexing/EmbeddingPipeline.js.map +1 -0
- package/dist/application/indexing/IndexBuilder.d.ts +112 -0
- package/dist/application/indexing/IndexBuilder.js +370 -0
- package/dist/application/indexing/IndexBuilder.js.map +1 -0
- package/dist/application/indexing/IndexingProgress.d.ts +34 -0
- package/dist/application/indexing/IndexingProgress.js +2 -0
- package/dist/application/indexing/IndexingProgress.js.map +1 -0
- package/dist/application/operations/Deadline.d.ts +13 -0
- package/dist/application/operations/Deadline.js +29 -0
- package/dist/application/operations/Deadline.js.map +1 -0
- package/dist/application/operations/HealthMonitor.d.ts +58 -0
- package/dist/application/operations/HealthMonitor.js +128 -0
- package/dist/application/operations/HealthMonitor.js.map +1 -0
- package/dist/application/operations/IndexAlternatives.d.ts +35 -0
- package/dist/application/operations/IndexAlternatives.js +61 -0
- package/dist/application/operations/IndexAlternatives.js.map +1 -0
- package/dist/application/operations/IndexInventory.d.ts +69 -0
- package/dist/application/operations/IndexInventory.js +99 -0
- package/dist/application/operations/IndexInventory.js.map +1 -0
- package/dist/application/operations/StatusService.d.ts +90 -0
- package/dist/application/operations/StatusService.js +171 -0
- package/dist/application/operations/StatusService.js.map +1 -0
- package/dist/application/operations/WatchService.d.ts +67 -0
- package/dist/application/operations/WatchService.js +145 -0
- package/dist/application/operations/WatchService.js.map +1 -0
- package/dist/application/operations/WorkingTreeDiff.d.ts +19 -0
- package/dist/application/operations/WorkingTreeDiff.js +36 -0
- package/dist/application/operations/WorkingTreeDiff.js.map +1 -0
- package/dist/application/research/ResearchAgent.d.ts +68 -0
- package/dist/application/research/ResearchAgent.js +201 -0
- package/dist/application/research/ResearchAgent.js.map +1 -0
- package/dist/application/research/ResearchPrompts.d.ts +16 -0
- package/dist/application/research/ResearchPrompts.js +34 -0
- package/dist/application/research/ResearchPrompts.js.map +1 -0
- package/dist/application/search/SearchCriteria.d.ts +37 -0
- package/dist/application/search/SearchCriteria.js +48 -0
- package/dist/application/search/SearchCriteria.js.map +1 -0
- package/dist/application/search/SearchService.d.ts +36 -0
- package/dist/application/search/SearchService.js +108 -0
- package/dist/application/search/SearchService.js.map +1 -0
- package/dist/application/search/SearchTargetResolver.d.ts +56 -0
- package/dist/application/search/SearchTargetResolver.js +104 -0
- package/dist/application/search/SearchTargetResolver.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +4 -953
- package/dist/cli.js.map +1 -1
- package/dist/domain/config/ConfigSource.d.ts +16 -0
- package/dist/domain/config/ConfigSource.js +2 -0
- package/dist/domain/config/ConfigSource.js.map +1 -0
- package/dist/domain/config/LmgrepConfig.d.ts +53 -0
- package/dist/domain/config/LmgrepConfig.js +2 -0
- package/dist/domain/config/LmgrepConfig.js.map +1 -0
- package/dist/domain/corpus/Chunk.d.ts +49 -0
- package/dist/domain/corpus/Chunk.js +60 -0
- package/dist/domain/corpus/Chunk.js.map +1 -0
- package/dist/domain/corpus/CodeLocation.d.ts +18 -0
- package/dist/domain/corpus/CodeLocation.js +34 -0
- package/dist/domain/corpus/CodeLocation.js.map +1 -0
- package/dist/domain/corpus/ContentHash.d.ts +15 -0
- package/dist/domain/corpus/ContentHash.js +30 -0
- package/dist/domain/corpus/ContentHash.js.map +1 -0
- package/dist/domain/corpus/FileVersion.d.ts +31 -0
- package/dist/domain/corpus/FileVersion.js +47 -0
- package/dist/domain/corpus/FileVersion.js.map +1 -0
- package/dist/domain/corpus/SourceFile.d.ts +26 -0
- package/dist/domain/corpus/SourceFile.js +47 -0
- package/dist/domain/corpus/SourceFile.js.map +1 -0
- package/dist/domain/corpus/Vector.d.ts +37 -0
- package/dist/domain/corpus/Vector.js +96 -0
- package/dist/domain/corpus/Vector.js.map +1 -0
- package/dist/domain/ports/ChatModelPort.d.ts +57 -0
- package/dist/domain/ports/ChatModelPort.js +2 -0
- package/dist/domain/ports/ChatModelPort.js.map +1 -0
- package/dist/domain/ports/ChunkRepositoryPort.d.ts +42 -0
- package/dist/domain/ports/ChunkRepositoryPort.js +2 -0
- package/dist/domain/ports/ChunkRepositoryPort.js.map +1 -0
- package/dist/domain/ports/ChunkerPort.d.ts +5 -0
- package/dist/domain/ports/ChunkerPort.js +2 -0
- package/dist/domain/ports/ChunkerPort.js.map +1 -0
- package/dist/domain/ports/DatabaseSessionPort.d.ts +10 -0
- package/dist/domain/ports/DatabaseSessionPort.js +2 -0
- package/dist/domain/ports/DatabaseSessionPort.js.map +1 -0
- package/dist/domain/ports/EmbedderPort.d.ts +14 -0
- package/dist/domain/ports/EmbedderPort.js +2 -0
- package/dist/domain/ports/EmbedderPort.js.map +1 -0
- package/dist/domain/ports/FileManifestRepositoryPort.d.ts +32 -0
- package/dist/domain/ports/FileManifestRepositoryPort.js +2 -0
- package/dist/domain/ports/FileManifestRepositoryPort.js.map +1 -0
- package/dist/domain/ports/GitPort.d.ts +24 -0
- package/dist/domain/ports/GitPort.js +2 -0
- package/dist/domain/ports/GitPort.js.map +1 -0
- package/dist/domain/ports/IndexMaintenancePort.d.ts +58 -0
- package/dist/domain/ports/IndexMaintenancePort.js +2 -0
- package/dist/domain/ports/IndexMaintenancePort.js.map +1 -0
- package/dist/domain/ports/IndexMetadataPort.d.ts +23 -0
- package/dist/domain/ports/IndexMetadataPort.js +2 -0
- package/dist/domain/ports/IndexMetadataPort.js.map +1 -0
- package/dist/domain/ports/LockPort.d.ts +17 -0
- package/dist/domain/ports/LockPort.js +2 -0
- package/dist/domain/ports/LockPort.js.map +1 -0
- package/dist/domain/ports/LoggerPort.d.ts +5 -0
- package/dist/domain/ports/LoggerPort.js +2 -0
- package/dist/domain/ports/LoggerPort.js.map +1 -0
- package/dist/domain/ports/ProjectIndexesPort.d.ts +20 -0
- package/dist/domain/ports/ProjectIndexesPort.js +2 -0
- package/dist/domain/ports/ProjectIndexesPort.js.map +1 -0
- package/dist/domain/ports/ProjectRegistryPort.d.ts +42 -0
- package/dist/domain/ports/ProjectRegistryPort.js +2 -0
- package/dist/domain/ports/ProjectRegistryPort.js.map +1 -0
- package/dist/domain/ports/StateDirectoryPort.d.ts +29 -0
- package/dist/domain/ports/StateDirectoryPort.js +2 -0
- package/dist/domain/ports/StateDirectoryPort.js.map +1 -0
- package/dist/domain/ports/WorkspacePort.d.ts +38 -0
- package/dist/domain/ports/WorkspacePort.js +2 -0
- package/dist/domain/ports/WorkspacePort.js.map +1 -0
- package/dist/domain/project/Branch.d.ts +20 -0
- package/dist/domain/project/Branch.js +33 -0
- package/dist/domain/project/Branch.js.map +1 -0
- package/dist/domain/project/DatabaseLocation.d.ts +32 -0
- package/dist/domain/project/DatabaseLocation.js +35 -0
- package/dist/domain/project/DatabaseLocation.js.map +1 -0
- package/dist/domain/project/IndexMetadata.d.ts +17 -0
- package/dist/domain/project/IndexMetadata.js +2 -0
- package/dist/domain/project/IndexMetadata.js.map +1 -0
- package/dist/domain/project/ModelIdentity.d.ts +58 -0
- package/dist/domain/project/ModelIdentity.js +97 -0
- package/dist/domain/project/ModelIdentity.js.map +1 -0
- package/dist/domain/project/Project.d.ts +17 -0
- package/dist/domain/project/Project.js +21 -0
- package/dist/domain/project/Project.js.map +1 -0
- package/dist/domain/project/ProjectId.d.ts +28 -0
- package/dist/domain/project/ProjectId.js +58 -0
- package/dist/domain/project/ProjectId.js.map +1 -0
- package/dist/domain/project/ProjectLocator.d.ts +112 -0
- package/dist/domain/project/ProjectLocator.js +178 -0
- package/dist/domain/project/ProjectLocator.js.map +1 -0
- package/dist/domain/research/Citation.d.ts +27 -0
- package/dist/domain/research/Citation.js +43 -0
- package/dist/domain/research/Citation.js.map +1 -0
- package/dist/domain/research/EvidenceLedger.d.ts +47 -0
- package/dist/domain/research/EvidenceLedger.js +111 -0
- package/dist/domain/research/EvidenceLedger.js.map +1 -0
- package/dist/domain/research/ResearchTrace.d.ts +19 -0
- package/dist/domain/research/ResearchTrace.js +22 -0
- package/dist/domain/research/ResearchTrace.js.map +1 -0
- package/dist/domain/retrieval/Hit.d.ts +19 -0
- package/dist/domain/retrieval/Hit.js +28 -0
- package/dist/domain/retrieval/Hit.js.map +1 -0
- package/dist/domain/retrieval/HitList.d.ts +35 -0
- package/dist/domain/retrieval/HitList.js +81 -0
- package/dist/domain/retrieval/HitList.js.map +1 -0
- package/dist/domain/retrieval/MissingIndexError.d.ts +11 -0
- package/dist/domain/retrieval/MissingIndexError.js +15 -0
- package/dist/domain/retrieval/MissingIndexError.js.map +1 -0
- package/dist/index.d.ts +43 -45
- package/dist/index.js +30 -567
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/ai/AiSdkChatModel.d.ts +31 -0
- package/dist/infrastructure/ai/AiSdkChatModel.js +137 -0
- package/dist/infrastructure/ai/AiSdkChatModel.js.map +1 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.d.ts +28 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.js +79 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.js.map +1 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.d.ts +21 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.js +40 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.js.map +1 -0
- package/dist/infrastructure/ai/LmStudioProbe.d.ts +18 -0
- package/dist/infrastructure/ai/LmStudioProbe.js +49 -0
- package/dist/infrastructure/ai/LmStudioProbe.js.map +1 -0
- package/dist/infrastructure/ai/LocalModelReloader.d.ts +21 -0
- package/dist/infrastructure/ai/LocalModelReloader.js +61 -0
- package/dist/infrastructure/ai/LocalModelReloader.js.map +1 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.d.ts +36 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.js +61 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.js.map +1 -0
- package/dist/infrastructure/ai/ModelRuntime.d.ts +32 -0
- package/dist/infrastructure/ai/ModelRuntime.js +2 -0
- package/dist/infrastructure/ai/ModelRuntime.js.map +1 -0
- package/dist/infrastructure/ai/OllamaProbe.d.ts +21 -0
- package/dist/infrastructure/ai/OllamaProbe.js +69 -0
- package/dist/infrastructure/ai/OllamaProbe.js.map +1 -0
- package/dist/infrastructure/ai/ProviderFailure.d.ts +16 -0
- package/dist/infrastructure/ai/ProviderFailure.js +35 -0
- package/dist/infrastructure/ai/ProviderFailure.js.map +1 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.d.ts +13 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.js +49 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.js.map +1 -0
- package/dist/infrastructure/ai/ProviderRegistry.d.ts +37 -0
- package/dist/infrastructure/ai/ProviderRegistry.js +55 -0
- package/dist/infrastructure/ai/ProviderRegistry.js.map +1 -0
- package/dist/infrastructure/fs/ConfigLoader.d.ts +59 -0
- package/dist/infrastructure/fs/ConfigLoader.js +194 -0
- package/dist/infrastructure/fs/ConfigLoader.js.map +1 -0
- package/dist/infrastructure/fs/DatabaseLocks.d.ts +52 -0
- package/dist/infrastructure/fs/DatabaseLocks.js +92 -0
- package/dist/infrastructure/fs/DatabaseLocks.js.map +1 -0
- package/dist/infrastructure/fs/DiskUsage.d.ts +6 -0
- package/dist/infrastructure/fs/DiskUsage.js +41 -0
- package/dist/infrastructure/fs/DiskUsage.js.map +1 -0
- package/dist/infrastructure/fs/IndexableFileRules.d.ts +33 -0
- package/dist/infrastructure/fs/IndexableFileRules.js +177 -0
- package/dist/infrastructure/fs/IndexableFileRules.js.map +1 -0
- package/dist/infrastructure/fs/Loggers.d.ts +14 -0
- package/dist/infrastructure/fs/Loggers.js +18 -0
- package/dist/infrastructure/fs/Loggers.js.map +1 -0
- package/dist/infrastructure/fs/PidFileLock.d.ts +40 -0
- package/dist/infrastructure/fs/PidFileLock.js +97 -0
- package/dist/infrastructure/fs/PidFileLock.js.map +1 -0
- package/dist/infrastructure/fs/ProjectIndexes.d.ts +8 -0
- package/dist/infrastructure/fs/ProjectIndexes.js +35 -0
- package/dist/infrastructure/fs/ProjectIndexes.js.map +1 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.d.ts +42 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.js +86 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.js.map +1 -0
- package/dist/infrastructure/fs/ProjectRegistry.d.ts +25 -0
- package/dist/infrastructure/fs/ProjectRegistry.js +83 -0
- package/dist/infrastructure/fs/ProjectRegistry.js.map +1 -0
- package/dist/infrastructure/fs/StateDirectory.d.ts +28 -0
- package/dist/infrastructure/fs/StateDirectory.js +71 -0
- package/dist/infrastructure/fs/StateDirectory.js.map +1 -0
- package/dist/infrastructure/fs/Workspace.d.ts +25 -0
- package/dist/infrastructure/fs/Workspace.js +90 -0
- package/dist/infrastructure/fs/Workspace.js.map +1 -0
- package/dist/infrastructure/git/GitClient.d.ts +34 -0
- package/dist/infrastructure/git/GitClient.js +74 -0
- package/dist/infrastructure/git/GitClient.js.map +1 -0
- package/dist/infrastructure/lancedb/ChunkRepository.d.ts +38 -0
- package/dist/infrastructure/lancedb/ChunkRepository.js +166 -0
- package/dist/infrastructure/lancedb/ChunkRepository.js.map +1 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.d.ts +22 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.js +74 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.js.map +1 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.d.ts +34 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.js +137 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.js.map +1 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.d.ts +53 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.js +227 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.js.map +1 -0
- package/dist/infrastructure/lancedb/LanceTables.d.ts +67 -0
- package/dist/infrastructure/lancedb/LanceTables.js +159 -0
- package/dist/infrastructure/lancedb/LanceTables.js.map +1 -0
- package/dist/{lib/native-tuning.js → infrastructure/lancedb/NativeTuning.js} +1 -1
- package/dist/infrastructure/lancedb/NativeTuning.js.map +1 -0
- package/dist/infrastructure/lancedb/RowReplication.d.ts +27 -0
- package/dist/infrastructure/lancedb/RowReplication.js +82 -0
- package/dist/infrastructure/lancedb/RowReplication.js.map +1 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.d.ts +60 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.js +72 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.js.map +1 -0
- package/dist/infrastructure/p2p/IndexShare.d.ts +45 -0
- package/dist/infrastructure/p2p/IndexShare.js +160 -0
- package/dist/infrastructure/p2p/IndexShare.js.map +1 -0
- package/dist/infrastructure/p2p/PeerSwarm.d.ts +16 -0
- package/dist/infrastructure/p2p/PeerSwarm.js +41 -0
- package/dist/infrastructure/p2p/PeerSwarm.js.map +1 -0
- package/dist/infrastructure/p2p/SecureChannel.d.ts +60 -0
- package/dist/infrastructure/p2p/SecureChannel.js +71 -0
- package/dist/infrastructure/p2p/SecureChannel.js.map +1 -0
- package/dist/infrastructure/p2p/ShareCode.d.ts +25 -0
- package/dist/infrastructure/p2p/ShareCode.js +304 -0
- package/dist/infrastructure/p2p/ShareCode.js.map +1 -0
- package/dist/infrastructure/process/ProcessRegistry.d.ts +50 -0
- package/dist/infrastructure/process/ProcessRegistry.js +109 -0
- package/dist/infrastructure/process/ProcessRegistry.js.map +1 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.d.ts +45 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.js +159 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.js.map +1 -0
- package/dist/infrastructure/treesitter/LanguageCatalog.d.ts +30 -0
- package/dist/{lib/chunker/languages.js → infrastructure/treesitter/LanguageCatalog.js} +34 -29
- package/dist/infrastructure/treesitter/LanguageCatalog.js.map +1 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.d.ts +15 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.js +42 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.js.map +1 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.d.ts +42 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.js +163 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.js.map +1 -0
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +14 -72
- package/dist/mcp.js.map +1 -1
- package/dist/presentation/cli/Cli.d.ts +31 -0
- package/dist/presentation/cli/Cli.js +120 -0
- package/dist/presentation/cli/Cli.js.map +1 -0
- package/dist/presentation/cli/CliOptions.d.ts +18 -0
- package/dist/presentation/cli/CliOptions.js +25 -0
- package/dist/presentation/cli/CliOptions.js.map +1 -0
- package/dist/presentation/cli/CommandContext.d.ts +50 -0
- package/dist/presentation/cli/CommandContext.js +88 -0
- package/dist/presentation/cli/CommandContext.js.map +1 -0
- package/dist/presentation/cli/ConfigTemplate.d.ts +31 -0
- package/dist/presentation/cli/ConfigTemplate.js +83 -0
- package/dist/presentation/cli/ConfigTemplate.js.map +1 -0
- package/dist/presentation/cli/Renderer.d.ts +90 -0
- package/dist/presentation/cli/Renderer.js +290 -0
- package/dist/presentation/cli/Renderer.js.map +1 -0
- package/dist/presentation/cli/commands/AskCommand.d.ts +14 -0
- package/dist/presentation/cli/commands/AskCommand.js +48 -0
- package/dist/presentation/cli/commands/AskCommand.js.map +1 -0
- package/dist/presentation/cli/commands/CompletionsCommand.d.ts +18 -0
- package/dist/presentation/cli/commands/CompletionsCommand.js +96 -0
- package/dist/presentation/cli/commands/CompletionsCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ConfigCommands.d.ts +55 -0
- package/dist/presentation/cli/commands/ConfigCommands.js +204 -0
- package/dist/presentation/cli/commands/ConfigCommands.js.map +1 -0
- package/dist/presentation/cli/commands/IndexCommand.d.ts +18 -0
- package/dist/presentation/cli/commands/IndexCommand.js +54 -0
- package/dist/presentation/cli/commands/IndexCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ProjectsCommand.d.ts +48 -0
- package/dist/presentation/cli/commands/ProjectsCommand.js +240 -0
- package/dist/presentation/cli/commands/ProjectsCommand.js.map +1 -0
- package/dist/presentation/cli/commands/SearchCommand.d.ts +19 -0
- package/dist/presentation/cli/commands/SearchCommand.js +55 -0
- package/dist/presentation/cli/commands/SearchCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ServerCommands.d.ts +13 -0
- package/dist/presentation/cli/commands/ServerCommands.js +40 -0
- package/dist/presentation/cli/commands/ServerCommands.js.map +1 -0
- package/dist/presentation/cli/commands/ShareCommands.d.ts +22 -0
- package/dist/presentation/cli/commands/ShareCommands.js +134 -0
- package/dist/presentation/cli/commands/ShareCommands.js.map +1 -0
- package/dist/presentation/cli/commands/StatusCommand.d.ts +15 -0
- package/dist/presentation/cli/commands/StatusCommand.js +53 -0
- package/dist/presentation/cli/commands/StatusCommand.js.map +1 -0
- package/dist/presentation/mcp/HitFormatter.d.ts +17 -0
- package/dist/presentation/mcp/HitFormatter.js +42 -0
- package/dist/presentation/mcp/HitFormatter.js.map +1 -0
- package/dist/presentation/mcp/IndexWatchController.d.ts +17 -0
- package/dist/presentation/mcp/IndexWatchController.js +31 -0
- package/dist/presentation/mcp/IndexWatchController.js.map +1 -0
- package/dist/presentation/mcp/LmgrepCore.d.ts +66 -0
- package/dist/presentation/mcp/LmgrepCore.js +178 -0
- package/dist/presentation/mcp/LmgrepCore.js.map +1 -0
- package/dist/presentation/mcp/McpServer.d.ts +18 -0
- package/dist/presentation/mcp/McpServer.js +63 -0
- package/dist/presentation/mcp/McpServer.js.map +1 -0
- package/dist/presentation/mcp/ToolDescriptions.d.ts +40 -0
- package/dist/presentation/mcp/ToolDescriptions.js +85 -0
- package/dist/presentation/mcp/ToolDescriptions.js.map +1 -0
- package/package.json +84 -89
- package/dist/lib/build.d.ts +0 -21
- package/dist/lib/build.js +0 -374
- package/dist/lib/build.js.map +0 -1
- package/dist/lib/chunker/context.d.ts +0 -21
- package/dist/lib/chunker/context.js +0 -131
- package/dist/lib/chunker/context.js.map +0 -1
- package/dist/lib/chunker/index.d.ts +0 -7
- package/dist/lib/chunker/index.js +0 -209
- package/dist/lib/chunker/index.js.map +0 -1
- package/dist/lib/chunker/languages.d.ts +0 -15
- package/dist/lib/chunker/languages.js.map +0 -1
- package/dist/lib/config.d.ts +0 -12
- package/dist/lib/config.js +0 -83
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/embedder.d.ts +0 -65
- package/dist/lib/embedder.js +0 -236
- package/dist/lib/embedder.js.map +0 -1
- package/dist/lib/facet-session.d.ts +0 -44
- package/dist/lib/facet-session.js +0 -125
- package/dist/lib/facet-session.js.map +0 -1
- package/dist/lib/native-tuning.js.map +0 -1
- package/dist/lib/p2p.d.ts +0 -32
- package/dist/lib/p2p.js +0 -281
- package/dist/lib/p2p.js.map +0 -1
- package/dist/lib/providers.d.ts +0 -1
- package/dist/lib/providers.js +0 -41
- package/dist/lib/providers.js.map +0 -1
- package/dist/lib/repair.d.ts +0 -10
- package/dist/lib/repair.js +0 -57
- package/dist/lib/repair.js.map +0 -1
- package/dist/lib/scanner.d.ts +0 -34
- package/dist/lib/scanner.js +0 -242
- package/dist/lib/scanner.js.map +0 -1
- package/dist/lib/search-tool.d.ts +0 -55
- package/dist/lib/search-tool.js +0 -319
- package/dist/lib/search-tool.js.map +0 -1
- package/dist/lib/serve.d.ts +0 -11
- package/dist/lib/serve.js +0 -144
- package/dist/lib/serve.js.map +0 -1
- package/dist/lib/store.d.ts +0 -252
- package/dist/lib/store.js +0 -1216
- package/dist/lib/store.js.map +0 -1
- package/dist/lib/types.d.ts +0 -194
- package/dist/lib/types.js +0 -13
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/vocab.d.ts +0 -20
- package/dist/lib/vocab.js +0 -275
- package/dist/lib/vocab.js.map +0 -1
- /package/dist/{lib/native-tuning.d.ts → infrastructure/lancedb/NativeTuning.d.ts} +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Chunk } from "../../domain/corpus/Chunk.js";
|
|
2
|
+
import { CodeLocation } from "../../domain/corpus/CodeLocation.js";
|
|
3
|
+
import { ContentHash } from "../../domain/corpus/ContentHash.js";
|
|
4
|
+
import { FileVersion } from "../../domain/corpus/FileVersion.js";
|
|
5
|
+
import { Hit } from "../../domain/retrieval/Hit.js";
|
|
6
|
+
import { HitList } from "../../domain/retrieval/HitList.js";
|
|
7
|
+
import { MissingIndexError } from "../../domain/retrieval/MissingIndexError.js";
|
|
8
|
+
import { LanceTables, TableName } from "./LanceTables.js";
|
|
9
|
+
import { SEARCH_COLUMNS, VectorIndexPolicy } from "./VectorIndexPolicy.js";
|
|
10
|
+
/**
|
|
11
|
+
* Embedded chunks in LanceDB.
|
|
12
|
+
*
|
|
13
|
+
* Branch scoping lives here because it is a property of how chunks are stored:
|
|
14
|
+
* they are shared across branches by content hash, so a query must intersect
|
|
15
|
+
* them with the manifest of file versions the branch actually references.
|
|
16
|
+
*/
|
|
17
|
+
export class ChunkRepository {
|
|
18
|
+
tables;
|
|
19
|
+
manifest;
|
|
20
|
+
branch;
|
|
21
|
+
constructor(tables, manifest, branch) {
|
|
22
|
+
this.tables = tables;
|
|
23
|
+
this.manifest = manifest;
|
|
24
|
+
this.branch = branch;
|
|
25
|
+
}
|
|
26
|
+
async add(chunks) {
|
|
27
|
+
if (chunks.length === 0)
|
|
28
|
+
return;
|
|
29
|
+
const records = chunks.map(({ chunk, vector }) => this.toRow(chunk, vector));
|
|
30
|
+
const { table, seeded } = await this.tables.tableOrCreate(TableName.Chunks, records);
|
|
31
|
+
if (!seeded)
|
|
32
|
+
await table.add(records);
|
|
33
|
+
}
|
|
34
|
+
async search(query) {
|
|
35
|
+
const table = await this.tables.table(TableName.Chunks);
|
|
36
|
+
if (!table) {
|
|
37
|
+
throw new MissingIndexError();
|
|
38
|
+
}
|
|
39
|
+
const versions = query.scopeToBranch
|
|
40
|
+
? await this.manifest.branchVersions()
|
|
41
|
+
: undefined;
|
|
42
|
+
// Over-fetch: branch/version filtering and dedup both discard rows, so
|
|
43
|
+
// pull extra to still return `limit` distinct results.
|
|
44
|
+
const fetchLimit = versions ? query.limit * 3 : query.limit * 2;
|
|
45
|
+
let builder = table
|
|
46
|
+
.query()
|
|
47
|
+
.nearestTo(query.vector.toArray())
|
|
48
|
+
.limit(fetchLimit)
|
|
49
|
+
.refineFactor(VectorIndexPolicy.REFINE_FACTOR)
|
|
50
|
+
.select([...SEARCH_COLUMNS]);
|
|
51
|
+
const predicate = this.buildPredicate(query);
|
|
52
|
+
if (predicate)
|
|
53
|
+
builder = builder.where(predicate);
|
|
54
|
+
const rows = await builder.toArray();
|
|
55
|
+
let hits = HitList.of(rows.map((r) => this.toHit(r)));
|
|
56
|
+
if (versions) {
|
|
57
|
+
hits = hits.filtered((h) => h.fileVersion.matches(versions.versionOf(h.location.filePath)));
|
|
58
|
+
}
|
|
59
|
+
return hits.deduplicated().takeAtMost(query.limit);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Delete chunks for files no longer referenced by ANY branch. A path still
|
|
63
|
+
* present in another branch's manifest keeps its chunks — they are shared
|
|
64
|
+
* by content, so deleting them would blank that branch's results.
|
|
65
|
+
*/
|
|
66
|
+
async deleteByFiles(filePaths) {
|
|
67
|
+
const table = await this.tables.table(TableName.Chunks);
|
|
68
|
+
if (!table || filePaths.length === 0)
|
|
69
|
+
return;
|
|
70
|
+
const entries = await this.manifest.allEntries();
|
|
71
|
+
const referencedElsewhere = new Set(entries
|
|
72
|
+
.filter((e) => !e.branch.equals(this.branch))
|
|
73
|
+
.map((e) => e.filePath));
|
|
74
|
+
const toDelete = filePaths.filter((p) => !referencedElsewhere.has(p));
|
|
75
|
+
if (toDelete.length > 0) {
|
|
76
|
+
await LanceTables.deleteIn(table, "filePath", toDelete);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async existingHashes(hashes) {
|
|
80
|
+
const table = await this.tables.table(TableName.Chunks);
|
|
81
|
+
if (!table || hashes.length === 0)
|
|
82
|
+
return new Set();
|
|
83
|
+
const unique = [...new Set(hashes.map((h) => h.toString()))];
|
|
84
|
+
return LanceTables.selectIn(table, "hash", unique);
|
|
85
|
+
}
|
|
86
|
+
async count() {
|
|
87
|
+
const table = await this.tables.table(TableName.Chunks);
|
|
88
|
+
return table ? table.countRows() : 0;
|
|
89
|
+
}
|
|
90
|
+
async hashesByFile() {
|
|
91
|
+
const table = await this.tables.table(TableName.Chunks);
|
|
92
|
+
if (!table)
|
|
93
|
+
return new Map();
|
|
94
|
+
const rows = await table.query().select(["filePath", "hash"]).toArray();
|
|
95
|
+
const map = new Map();
|
|
96
|
+
for (const row of rows) {
|
|
97
|
+
const fp = row.filePath;
|
|
98
|
+
const existing = map.get(fp) ?? [];
|
|
99
|
+
existing.push(row.hash);
|
|
100
|
+
map.set(fp, existing);
|
|
101
|
+
}
|
|
102
|
+
return map;
|
|
103
|
+
}
|
|
104
|
+
async allHashes() {
|
|
105
|
+
const table = await this.tables.table(TableName.Chunks);
|
|
106
|
+
if (!table)
|
|
107
|
+
return new Set();
|
|
108
|
+
const rows = await table.query().select(["hash"]).toArray();
|
|
109
|
+
return new Set(rows.map((r) => r.hash));
|
|
110
|
+
}
|
|
111
|
+
async *streamTexts(batchSize = 1000) {
|
|
112
|
+
const table = await this.tables.table(TableName.Chunks);
|
|
113
|
+
if (!table)
|
|
114
|
+
return;
|
|
115
|
+
const rows = await table.query().select(["name", "content"]).toArray();
|
|
116
|
+
for (let i = 0; i < rows.length; i += batchSize) {
|
|
117
|
+
yield rows.slice(i, i + batchSize).map((r) => ({
|
|
118
|
+
name: r.name ?? "",
|
|
119
|
+
content: r.content ?? "",
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
buildPredicate(query) {
|
|
124
|
+
const conditions = [];
|
|
125
|
+
if (query.filePrefix) {
|
|
126
|
+
conditions.push(`filePath LIKE '${LanceTables.quote(query.filePrefix)}%'`);
|
|
127
|
+
}
|
|
128
|
+
if (query.types && query.types.length > 0) {
|
|
129
|
+
const escaped = query.types.map((t) => `'${LanceTables.quote(t)}'`);
|
|
130
|
+
conditions.push(`type IN (${escaped.join(", ")})`);
|
|
131
|
+
}
|
|
132
|
+
return conditions.length > 0 ? conditions.join(" AND ") : undefined;
|
|
133
|
+
}
|
|
134
|
+
toRow(chunk, vector) {
|
|
135
|
+
return {
|
|
136
|
+
id: chunk.id,
|
|
137
|
+
filePath: chunk.location.filePath,
|
|
138
|
+
startLine: chunk.location.startLine,
|
|
139
|
+
endLine: chunk.location.endLine,
|
|
140
|
+
type: chunk.type,
|
|
141
|
+
name: chunk.name,
|
|
142
|
+
content: chunk.content,
|
|
143
|
+
context: chunk.context,
|
|
144
|
+
hash: chunk.hash.toString(),
|
|
145
|
+
fileHash: chunk.fileVersion.toStored(),
|
|
146
|
+
vector: vector.toArray(),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
toHit(row) {
|
|
150
|
+
const distance = row._distance;
|
|
151
|
+
return new Hit(row.id, new CodeLocation(row.filePath, row.startLine, row.endLine), row.type, row.name, row.content, row.context, distance != null ? 1 - distance : 0, FileVersion.fromStored(row.fileHash));
|
|
152
|
+
}
|
|
153
|
+
/** Rebuild a domain Chunk from a stored row — used by import and dedup. */
|
|
154
|
+
static rowToChunk(row) {
|
|
155
|
+
return new Chunk({
|
|
156
|
+
location: new CodeLocation(row.filePath, row.startLine, row.endLine),
|
|
157
|
+
type: row.type,
|
|
158
|
+
name: row.name,
|
|
159
|
+
content: row.content,
|
|
160
|
+
context: row.context,
|
|
161
|
+
hash: ContentHash.fromStored(row.hash),
|
|
162
|
+
fileVersion: FileVersion.fromStored(row.fileHash),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=ChunkRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChunkRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/lancedb/ChunkRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAUjE,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAiB3E;;;;;;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,GAAG,CAAC,SAAmB,EACvB,GAAG,CAAC,OAAiB,CACrB;YACD,IAAI,EAAE,GAAG,CAAC,IAAc;YACxB,IAAI,EAAE,GAAG,CAAC,IAAc;YACxB,OAAO,EAAE,GAAG,CAAC,OAAiB;YAC9B,OAAO,EAAE,GAAG,CAAC,OAAiB;YAC9B,IAAI,EAAE,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,IAAc,CAAC;YAChD,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,QAA8B,CAAC;SACvE,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Branch } from "../../domain/project/Branch.js";
|
|
2
|
+
import { type LanceTables } from "./LanceTables.js";
|
|
3
|
+
export interface ImportResult {
|
|
4
|
+
chunks: number;
|
|
5
|
+
files: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Copies chunks and manifest rows out of another lmgrep database.
|
|
9
|
+
*
|
|
10
|
+
* Rows move verbatim, embeddings included — the point of importing is to avoid
|
|
11
|
+
* re-embedding, so re-deriving anything here would defeat it. The source must
|
|
12
|
+
* therefore have been built with a compatible model; the caller reports the
|
|
13
|
+
* source's model so the user can check.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DatabaseImporter {
|
|
16
|
+
private readonly tables;
|
|
17
|
+
private readonly branch;
|
|
18
|
+
constructor(tables: LanceTables, branch: Branch);
|
|
19
|
+
importFrom(sourcePath: string): Promise<ImportResult>;
|
|
20
|
+
private copyChunks;
|
|
21
|
+
private copyFiles;
|
|
22
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { connect } from "@lancedb/lancedb";
|
|
2
|
+
import { TableName } from "./LanceTables.js";
|
|
3
|
+
/**
|
|
4
|
+
* Copies chunks and manifest rows out of another lmgrep database.
|
|
5
|
+
*
|
|
6
|
+
* Rows move verbatim, embeddings included — the point of importing is to avoid
|
|
7
|
+
* re-embedding, so re-deriving anything here would defeat it. The source must
|
|
8
|
+
* therefore have been built with a compatible model; the caller reports the
|
|
9
|
+
* source's model so the user can check.
|
|
10
|
+
*/
|
|
11
|
+
export class DatabaseImporter {
|
|
12
|
+
tables;
|
|
13
|
+
branch;
|
|
14
|
+
constructor(tables, branch) {
|
|
15
|
+
this.tables = tables;
|
|
16
|
+
this.branch = branch;
|
|
17
|
+
}
|
|
18
|
+
async importFrom(sourcePath) {
|
|
19
|
+
const source = await connect(sourcePath);
|
|
20
|
+
const available = await source.tableNames();
|
|
21
|
+
return {
|
|
22
|
+
chunks: available.includes(TableName.Chunks)
|
|
23
|
+
? await this.copyChunks(source)
|
|
24
|
+
: 0,
|
|
25
|
+
files: available.includes(TableName.Files)
|
|
26
|
+
? await this.copyFiles(source)
|
|
27
|
+
: 0,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async copyChunks(source) {
|
|
31
|
+
const rows = await (await source.openTable(TableName.Chunks))
|
|
32
|
+
.query()
|
|
33
|
+
.toArray();
|
|
34
|
+
if (rows.length === 0)
|
|
35
|
+
return 0;
|
|
36
|
+
// Arrow hands back typed arrays; LanceDB needs plain values to infer a
|
|
37
|
+
// schema when the destination table does not exist yet.
|
|
38
|
+
const records = rows.map((r) => ({
|
|
39
|
+
id: r.id,
|
|
40
|
+
filePath: r.filePath,
|
|
41
|
+
startLine: r.startLine,
|
|
42
|
+
endLine: r.endLine,
|
|
43
|
+
type: r.type,
|
|
44
|
+
name: r.name,
|
|
45
|
+
content: r.content,
|
|
46
|
+
context: r.context,
|
|
47
|
+
hash: r.hash,
|
|
48
|
+
fileHash: r.fileHash ?? "",
|
|
49
|
+
vector: Array.from(r.vector),
|
|
50
|
+
}));
|
|
51
|
+
const { table, seeded } = await this.tables.tableOrCreate(TableName.Chunks, records);
|
|
52
|
+
if (!seeded)
|
|
53
|
+
await table.add(records);
|
|
54
|
+
return records.length;
|
|
55
|
+
}
|
|
56
|
+
async copyFiles(source) {
|
|
57
|
+
const rows = await (await source.openTable(TableName.Files))
|
|
58
|
+
.query()
|
|
59
|
+
.toArray();
|
|
60
|
+
if (rows.length === 0)
|
|
61
|
+
return 0;
|
|
62
|
+
// Legacy databases predate the branch column; adopt ours for those.
|
|
63
|
+
const records = rows.map((r) => ({
|
|
64
|
+
filePath: r.filePath,
|
|
65
|
+
fileHash: r.fileHash,
|
|
66
|
+
branch: r.branch ?? this.branch.toString(),
|
|
67
|
+
}));
|
|
68
|
+
const { table, seeded } = await this.tables.tableOrCreate(TableName.Files, records);
|
|
69
|
+
if (!seeded)
|
|
70
|
+
await table.add(records);
|
|
71
|
+
return records.length;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=DatabaseImporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseImporter.js","sourceRoot":"","sources":["../../../src/infrastructure/lancedb/DatabaseImporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAoB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAO/D;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IAEV;IACA;IAFlB,YACkB,MAAmB,EACnB,MAAc;QADd,WAAM,GAAN,MAAM,CAAa;QACnB,WAAM,GAAN,MAAM,CAAQ;IAC7B,CAAC;IAEJ,KAAK,CAAC,UAAU,CAAC,UAAkB;QAClC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;QACzC,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;QAE5C,OAAO;YACN,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC;gBAC3C,CAAC,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;gBAC/B,CAAC,CAAC,CAAC;YACJ,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,K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B,MAA2C;QAE3C,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;aAC1D,KAAK,EAAE;aACP,OAAO,EAAE,CAAC;QACZ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QAEhC,oEAAoE;QACpE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAChC,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;SAC1C,CAAC,CAAC,CAAC;QAEJ,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CACxD,SAAS,CAAC,KAAK,EACf,OAAO,CACP,CAAC;QACF,IAAI,CAAC,MAAM;YAAE,MAAM,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC,MAAM,CAAC;IACvB,CAAC;CACD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ContentHash } from "../../domain/corpus/ContentHash.js";
|
|
2
|
+
import { FileManifest, type SourceFile } from "../../domain/corpus/SourceFile.js";
|
|
3
|
+
import type { FileManifestRepositoryPort, ManifestEntry } from "../../domain/ports/FileManifestRepositoryPort.js";
|
|
4
|
+
import { Branch } from "../../domain/project/Branch.js";
|
|
5
|
+
import { LanceTables } from "./LanceTables.js";
|
|
6
|
+
/**
|
|
7
|
+
* The branch-scoped file manifest in LanceDB.
|
|
8
|
+
*
|
|
9
|
+
* The current branch's manifest is cached because every search consults it to
|
|
10
|
+
* scope results, and re-reading it per query would dominate search latency.
|
|
11
|
+
* Anything that writes the manifest must {@link invalidate}.
|
|
12
|
+
*/
|
|
13
|
+
export declare class FileManifestRepository implements FileManifestRepositoryPort {
|
|
14
|
+
private readonly tables;
|
|
15
|
+
private readonly branch;
|
|
16
|
+
private cached;
|
|
17
|
+
constructor(tables: LanceTables, branch: Branch);
|
|
18
|
+
current(): Promise<FileManifest>;
|
|
19
|
+
branchVersions(): Promise<FileManifest | undefined>;
|
|
20
|
+
invalidate(): void;
|
|
21
|
+
upsert(entries: SourceFile[]): Promise<void>;
|
|
22
|
+
deleteFiles(filePaths: string[]): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Which of these file versions any branch has already indexed. A hit means
|
|
25
|
+
* the content is embedded, so the file can be registered on this branch
|
|
26
|
+
* without re-chunking it.
|
|
27
|
+
*/
|
|
28
|
+
knownHashes(hashes: ContentHash[]): Promise<Set<string>>;
|
|
29
|
+
allEntries(): Promise<ManifestEntry[]>;
|
|
30
|
+
storedBranches(): Promise<string[]>;
|
|
31
|
+
deleteBranch(branch: string): Promise<void>;
|
|
32
|
+
/** Seed this branch's manifest from another's — used on a new branch. */
|
|
33
|
+
copyFromBranch(sourceBranch: string): Promise<number>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { ContentHash } from "../../domain/corpus/ContentHash.js";
|
|
2
|
+
import { FileManifest, } from "../../domain/corpus/SourceFile.js";
|
|
3
|
+
import { Branch } from "../../domain/project/Branch.js";
|
|
4
|
+
import { LanceTables, TableName } from "./LanceTables.js";
|
|
5
|
+
/**
|
|
6
|
+
* The branch-scoped file manifest in LanceDB.
|
|
7
|
+
*
|
|
8
|
+
* The current branch's manifest is cached because every search consults it to
|
|
9
|
+
* scope results, and re-reading it per query would dominate search latency.
|
|
10
|
+
* Anything that writes the manifest must {@link invalidate}.
|
|
11
|
+
*/
|
|
12
|
+
export class FileManifestRepository {
|
|
13
|
+
tables;
|
|
14
|
+
branch;
|
|
15
|
+
cached;
|
|
16
|
+
constructor(tables, branch) {
|
|
17
|
+
this.tables = tables;
|
|
18
|
+
this.branch = branch;
|
|
19
|
+
}
|
|
20
|
+
async current() {
|
|
21
|
+
const table = await this.tables.table(TableName.Files);
|
|
22
|
+
if (!table)
|
|
23
|
+
return FileManifest.empty();
|
|
24
|
+
const rows = await table
|
|
25
|
+
.query()
|
|
26
|
+
.where(`branch = '${this.branch.toSqlLiteral()}'`)
|
|
27
|
+
.select(["filePath", "fileHash"])
|
|
28
|
+
.toArray();
|
|
29
|
+
return FileManifest.fromEntries(rows.map((r) => [
|
|
30
|
+
r.filePath,
|
|
31
|
+
ContentHash.fromStored(r.fileHash),
|
|
32
|
+
]));
|
|
33
|
+
}
|
|
34
|
+
async branchVersions() {
|
|
35
|
+
if (this.cached)
|
|
36
|
+
return this.cached;
|
|
37
|
+
const table = await this.tables.table(TableName.Files);
|
|
38
|
+
if (!table)
|
|
39
|
+
return undefined;
|
|
40
|
+
this.cached = await this.current();
|
|
41
|
+
return this.cached;
|
|
42
|
+
}
|
|
43
|
+
invalidate() {
|
|
44
|
+
this.cached = undefined;
|
|
45
|
+
}
|
|
46
|
+
async upsert(entries) {
|
|
47
|
+
if (entries.length === 0)
|
|
48
|
+
return;
|
|
49
|
+
const records = entries.map((e) => ({
|
|
50
|
+
filePath: e.path,
|
|
51
|
+
fileHash: e.hash.toString(),
|
|
52
|
+
branch: this.branch.toString(),
|
|
53
|
+
}));
|
|
54
|
+
const { table, seeded } = await this.tables.tableOrCreate(TableName.Files, records);
|
|
55
|
+
if (seeded) {
|
|
56
|
+
this.invalidate();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// Replace this branch's rows for these paths, leaving other branches'
|
|
60
|
+
// rows for the same paths untouched.
|
|
61
|
+
const paths = records.map((r) => r.filePath);
|
|
62
|
+
for (let i = 0; i < paths.length; i += LanceTables.FILTER_BATCH_SIZE) {
|
|
63
|
+
const batch = paths.slice(i, i + LanceTables.FILTER_BATCH_SIZE);
|
|
64
|
+
await table.delete(`branch = '${this.branch.toSqlLiteral()}' AND ${LanceTables.inFilter("filePath", batch)}`);
|
|
65
|
+
}
|
|
66
|
+
await table.add(records);
|
|
67
|
+
this.invalidate();
|
|
68
|
+
}
|
|
69
|
+
async deleteFiles(filePaths) {
|
|
70
|
+
const table = await this.tables.table(TableName.Files);
|
|
71
|
+
if (!table || filePaths.length === 0)
|
|
72
|
+
return;
|
|
73
|
+
for (let i = 0; i < filePaths.length; i += LanceTables.FILTER_BATCH_SIZE) {
|
|
74
|
+
const batch = filePaths.slice(i, i + LanceTables.FILTER_BATCH_SIZE);
|
|
75
|
+
await table.delete(`branch = '${this.branch.toSqlLiteral()}' AND ${LanceTables.inFilter("filePath", batch)}`);
|
|
76
|
+
}
|
|
77
|
+
this.invalidate();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Which of these file versions any branch has already indexed. A hit means
|
|
81
|
+
* the content is embedded, so the file can be registered on this branch
|
|
82
|
+
* without re-chunking it.
|
|
83
|
+
*/
|
|
84
|
+
async knownHashes(hashes) {
|
|
85
|
+
const table = await this.tables.table(TableName.Files);
|
|
86
|
+
if (!table || hashes.length === 0)
|
|
87
|
+
return new Set();
|
|
88
|
+
return LanceTables.selectIn(table, "fileHash", hashes.map((h) => h.toString()));
|
|
89
|
+
}
|
|
90
|
+
async allEntries() {
|
|
91
|
+
const table = await this.tables.table(TableName.Files);
|
|
92
|
+
if (!table)
|
|
93
|
+
return [];
|
|
94
|
+
const rows = await table.query().toArray();
|
|
95
|
+
return rows.map((r) => ({
|
|
96
|
+
filePath: r.filePath,
|
|
97
|
+
fileHash: ContentHash.fromStored(r.fileHash),
|
|
98
|
+
branch: Branch.of(r.branch),
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
async storedBranches() {
|
|
102
|
+
const table = await this.tables.table(TableName.Files);
|
|
103
|
+
if (!table)
|
|
104
|
+
return [];
|
|
105
|
+
const rows = await table.query().select(["branch"]).toArray();
|
|
106
|
+
return [...new Set(rows.map((r) => r.branch))];
|
|
107
|
+
}
|
|
108
|
+
async deleteBranch(branch) {
|
|
109
|
+
const table = await this.tables.table(TableName.Files);
|
|
110
|
+
if (!table)
|
|
111
|
+
return;
|
|
112
|
+
await table.delete(`branch = '${LanceTables.quote(branch)}'`);
|
|
113
|
+
this.invalidate();
|
|
114
|
+
}
|
|
115
|
+
/** Seed this branch's manifest from another's — used on a new branch. */
|
|
116
|
+
async copyFromBranch(sourceBranch) {
|
|
117
|
+
const table = await this.tables.table(TableName.Files);
|
|
118
|
+
if (!table)
|
|
119
|
+
return 0;
|
|
120
|
+
const rows = await table
|
|
121
|
+
.query()
|
|
122
|
+
.where(`branch = '${LanceTables.quote(sourceBranch)}'`)
|
|
123
|
+
.select(["filePath", "fileHash"])
|
|
124
|
+
.toArray();
|
|
125
|
+
if (rows.length === 0)
|
|
126
|
+
return 0;
|
|
127
|
+
const records = rows.map((r) => ({
|
|
128
|
+
filePath: r.filePath,
|
|
129
|
+
fileHash: r.fileHash,
|
|
130
|
+
branch: this.branch.toString(),
|
|
131
|
+
}));
|
|
132
|
+
await table.add(records);
|
|
133
|
+
this.invalidate();
|
|
134
|
+
return records.length;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=FileManifestRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileManifestRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/lancedb/FileManifestRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EACN,YAAY,GAEZ,MAAM,mCAAmC,CAAC;AAK3C,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAQ1D;;;;;;GAMG;AACH,MAAM,OAAO,sBAAsB;IAIhB;IACA;IAJV,MAAM,CAA2B;IAEzC,YACkB,MAAmB,EACnB,MAAc;QADd,WAAM,GAAN,MAAM,CAAa;QACn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C,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;aAChC,OAAO,EAAE,CAAC;QACZ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QAEhC,MAAM,OAAO,GAAc,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC3C,QAAQ,EAAE,CAAC,CAAC,QAAkB;YAC9B,QAAQ,EAAE,CAAC,CAAC,QAAkB;YAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;SAC9B,CAAC,CAAC,CAAC;QACJ,MAAM,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,OAAO,CAAC,MAAM,CAAC;IACvB,CAAC;CACD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { FileManifestRepositoryPort } from "../../domain/ports/FileManifestRepositoryPort.js";
|
|
2
|
+
import type { DedupeReport, IndexMaintenancePort, OptimizeOptions, OptimizeReport, VectorIndexState } from "../../domain/ports/IndexMaintenancePort.js";
|
|
3
|
+
import { type LanceTables } from "./LanceTables.js";
|
|
4
|
+
/**
|
|
5
|
+
* Keeps the LanceDB tables compact and their ANN indexes current.
|
|
6
|
+
*
|
|
7
|
+
* Without a vector index LanceDB answers a search by brute force: it decodes
|
|
8
|
+
* every stored embedding to score it. At high dimensions that walks the whole
|
|
9
|
+
* table through memory per query, so peak RSS tracks index size roughly 1:1.
|
|
10
|
+
* IVF-PQ turns that into a handful of probes.
|
|
11
|
+
*
|
|
12
|
+
* Compaction matters for the same reason — small appends leave hundreds of
|
|
13
|
+
* fragments, each carrying its own decode buffers.
|
|
14
|
+
*/
|
|
15
|
+
export declare class IndexMaintenance implements IndexMaintenancePort {
|
|
16
|
+
private readonly tables;
|
|
17
|
+
private readonly manifest;
|
|
18
|
+
/** Tables holding embeddings, and therefore wanting a vector index. */
|
|
19
|
+
private static readonly VECTOR_TABLES;
|
|
20
|
+
constructor(tables: LanceTables, manifest: FileManifestRepositoryPort);
|
|
21
|
+
/**
|
|
22
|
+
* Cheap and idempotent when there is nothing to do, so it is safe to call
|
|
23
|
+
* after every build.
|
|
24
|
+
*/
|
|
25
|
+
optimize(options?: OptimizeOptions): Promise<OptimizeReport>;
|
|
26
|
+
/**
|
|
27
|
+
* What `lmgrep compact` runs: the same work as {@link optimize} but
|
|
28
|
+
* unconditional, plus compaction of the files table (which holds no
|
|
29
|
+
* embeddings, so it never needs a vector index).
|
|
30
|
+
*/
|
|
31
|
+
compact(): Promise<OptimizeReport>;
|
|
32
|
+
/**
|
|
33
|
+
* Remove tables no longer part of the schema.
|
|
34
|
+
*
|
|
35
|
+
* Databases built before faceting was removed still carry a `vocab` table
|
|
36
|
+
* holding one embedding per corpus term — nothing reads it now, and at
|
|
37
|
+
* full embedding width that is real disk. Dropping it here means users
|
|
38
|
+
* reclaim the space by running the command they already run.
|
|
39
|
+
*/
|
|
40
|
+
private dropLegacyTables;
|
|
41
|
+
private optimizeTable;
|
|
42
|
+
/**
|
|
43
|
+
* Remove rows that should not be there: exact id duplicates (from
|
|
44
|
+
* concurrent unlocked indexing) and chunks whose file version no branch
|
|
45
|
+
* references any more. Survivors are rewritten into a fresh table, which is
|
|
46
|
+
* also what reclaims the disk the dropped rows held.
|
|
47
|
+
*/
|
|
48
|
+
dedupe(): Promise<DedupeReport>;
|
|
49
|
+
vectorIndexState(): Promise<VectorIndexState>;
|
|
50
|
+
reset(): Promise<void>;
|
|
51
|
+
/** Arrow rows carry typed arrays; LanceDB needs plain values to re-infer a schema. */
|
|
52
|
+
private toPlainRow;
|
|
53
|
+
}
|