lmgrep 0.1.18 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +253 -62
- 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 +94 -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/DockerModelRunnerProbe.d.ts +16 -0
- package/dist/infrastructure/ai/DockerModelRunnerProbe.js +52 -0
- package/dist/infrastructure/ai/DockerModelRunnerProbe.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 +63 -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 +22 -0
- package/dist/infrastructure/ai/OllamaProbe.js +71 -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 +14 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.js +56 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.js.map +1 -0
- package/dist/infrastructure/ai/ProviderRegistry.d.ts +38 -0
- package/dist/infrastructure/ai/ProviderRegistry.js +63 -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/EmbeddedTreeSitterAssets.d.ts +8 -0
- package/dist/infrastructure/treesitter/EmbeddedTreeSitterAssets.js +12 -0
- package/dist/infrastructure/treesitter/EmbeddedTreeSitterAssets.js.map +1 -0
- package/dist/infrastructure/treesitter/LanguageCatalog.d.ts +30 -0
- package/dist/{lib/chunker/languages.js → infrastructure/treesitter/LanguageCatalog.js} +38 -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 +165 -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 +56 -0
- package/dist/presentation/cli/commands/ConfigCommands.js +220 -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 +93 -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,90 @@
|
|
|
1
|
+
import { readFileSync, statSync, watch } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { globSync } from "glob";
|
|
4
|
+
import { ContentHash } from "../../domain/corpus/ContentHash.js";
|
|
5
|
+
import { SourceFile } from "../../domain/corpus/SourceFile.js";
|
|
6
|
+
import { IndexableFileRules } from "./IndexableFileRules.js";
|
|
7
|
+
/** The working tree on the real filesystem. */
|
|
8
|
+
export class Workspace {
|
|
9
|
+
listFiles(cwd, extraIgnore, extensions) {
|
|
10
|
+
const rules = new IndexableFileRules(cwd, extraIgnore, extensions);
|
|
11
|
+
const all = globSync("**/*", { cwd, nodir: true, dot: false });
|
|
12
|
+
rules.loadNestedIgnores(all);
|
|
13
|
+
return all.filter((f) => rules.admits(f));
|
|
14
|
+
}
|
|
15
|
+
hashOf(cwd, filePath) {
|
|
16
|
+
try {
|
|
17
|
+
return ContentHash.of(readFileSync(join(cwd, filePath)));
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
modifiedSince(files, cwd, cutoffMs) {
|
|
24
|
+
return files.filter((f) => {
|
|
25
|
+
try {
|
|
26
|
+
return statSync(join(cwd, f)).mtimeMs >= cutoffMs;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Compare on-disk hashes against what the manifest recorded.
|
|
35
|
+
*
|
|
36
|
+
* Unreadable files are skipped rather than reported as changed — a
|
|
37
|
+
* transient read error should not evict a file from the index.
|
|
38
|
+
*/
|
|
39
|
+
detectChanges(files, manifest, cwd, force = false) {
|
|
40
|
+
const changed = [];
|
|
41
|
+
const current = new Map();
|
|
42
|
+
for (const file of files) {
|
|
43
|
+
const hash = this.hashOf(cwd, file);
|
|
44
|
+
if (!hash)
|
|
45
|
+
continue;
|
|
46
|
+
current.set(file, hash);
|
|
47
|
+
const stored = manifest.versionOf(file);
|
|
48
|
+
if (force || stored === undefined || !stored.equals(hash)) {
|
|
49
|
+
changed.push(new SourceFile(file, hash));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { changed, current };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Watch for changes, coalescing a burst into one callback.
|
|
56
|
+
*
|
|
57
|
+
* fs.watch's recursive mode misses events on Linux (new subdirectories,
|
|
58
|
+
* editor atomic saves); callers pair this with a periodic reconcile rather
|
|
59
|
+
* than trusting it alone.
|
|
60
|
+
*/
|
|
61
|
+
watch(cwd, extraIgnore, onChanges, debounceMs, extensions) {
|
|
62
|
+
const rules = new IndexableFileRules(cwd, extraIgnore, extensions);
|
|
63
|
+
let timer;
|
|
64
|
+
let pending = new Set();
|
|
65
|
+
const watcher = watch(cwd, { recursive: true }, (_event, filename) => {
|
|
66
|
+
if (!filename)
|
|
67
|
+
return;
|
|
68
|
+
if (!rules.hasIndexableExtension(filename))
|
|
69
|
+
return;
|
|
70
|
+
if (rules.isIgnored(filename))
|
|
71
|
+
return;
|
|
72
|
+
pending.add(filename);
|
|
73
|
+
if (timer)
|
|
74
|
+
clearTimeout(timer);
|
|
75
|
+
timer = setTimeout(() => {
|
|
76
|
+
const files = [...pending];
|
|
77
|
+
pending = new Set();
|
|
78
|
+
onChanges(files);
|
|
79
|
+
}, debounceMs);
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
close() {
|
|
83
|
+
if (timer)
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
watcher.close();
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=Workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Workspace.js","sourceRoot":"","sources":["../../../src/infrastructure/fs/Workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAO/D,OAAO,EAAE,kBAAkB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AAC;YAC/B,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBACvB,MAAM,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;gBAC3B,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;gBACpB,SAAS,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC,EAAE,UAAU,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,OAAO;YACN,KAAK;gBACJ,IAAI,KAAK;oBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;gBAC/B,OAAO,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC;SACD,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { GitPort } from "../../domain/ports/GitPort.js";
|
|
2
|
+
/**
|
|
3
|
+
* GitPort over the `git` binary.
|
|
4
|
+
*
|
|
5
|
+
* Every call is best-effort: a missing binary, a non-repo directory, or a
|
|
6
|
+
* detached/oprhaned state all surface as `undefined` rather than throwing,
|
|
7
|
+
* because every caller treats "not a git repo" as an ordinary case.
|
|
8
|
+
*/
|
|
9
|
+
export declare class GitClient implements GitPort {
|
|
10
|
+
private static readonly TIMEOUT_MS;
|
|
11
|
+
toplevel(cwd: string): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* `--git-common-dir` reports a path *relative to the invocation directory*
|
|
14
|
+
* (`../../.git` from a subdirectory), so it is resolved against that
|
|
15
|
+
* directory rather than used as given. `--path-format=absolute` would do
|
|
16
|
+
* the same but only on git 2.31 and later.
|
|
17
|
+
*/
|
|
18
|
+
commonDir(cwd: string): string | undefined;
|
|
19
|
+
currentBranch(repoRoot: string): string | undefined;
|
|
20
|
+
originUrl(repoRoot: string): string | undefined;
|
|
21
|
+
mergeBase(repoRoot: string, ref: string): string | undefined;
|
|
22
|
+
commitDistance(repoRoot: string, from: string, to: string): number | undefined;
|
|
23
|
+
localBranches(repoRoot: string): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Run git with an argv array rather than a command string.
|
|
26
|
+
*
|
|
27
|
+
* This must not go through a shell. Git's own format specifiers contain
|
|
28
|
+
* parentheses (`--format=%(refname:short)`), and branch names may legally
|
|
29
|
+
* contain `(`, `)`, `&`, `;`, `$` and quotes — all of which a shell would
|
|
30
|
+
* interpret. Passing a string here silently broke branch listing entirely
|
|
31
|
+
* and made any branch name with a metacharacter unusable.
|
|
32
|
+
*/
|
|
33
|
+
private run;
|
|
34
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* GitPort over the `git` binary.
|
|
5
|
+
*
|
|
6
|
+
* Every call is best-effort: a missing binary, a non-repo directory, or a
|
|
7
|
+
* detached/oprhaned state all surface as `undefined` rather than throwing,
|
|
8
|
+
* because every caller treats "not a git repo" as an ordinary case.
|
|
9
|
+
*/
|
|
10
|
+
export class GitClient {
|
|
11
|
+
static TIMEOUT_MS = 5000;
|
|
12
|
+
toplevel(cwd) {
|
|
13
|
+
return this.run(cwd, "rev-parse", "--show-toplevel");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `--git-common-dir` reports a path *relative to the invocation directory*
|
|
17
|
+
* (`../../.git` from a subdirectory), so it is resolved against that
|
|
18
|
+
* directory rather than used as given. `--path-format=absolute` would do
|
|
19
|
+
* the same but only on git 2.31 and later.
|
|
20
|
+
*/
|
|
21
|
+
commonDir(cwd) {
|
|
22
|
+
const out = this.run(cwd, "rev-parse", "--git-common-dir");
|
|
23
|
+
return out === undefined ? undefined : resolve(cwd, out);
|
|
24
|
+
}
|
|
25
|
+
currentBranch(repoRoot) {
|
|
26
|
+
return this.run(repoRoot, "rev-parse", "--abbrev-ref", "HEAD");
|
|
27
|
+
}
|
|
28
|
+
originUrl(repoRoot) {
|
|
29
|
+
return this.run(repoRoot, "remote", "get-url", "origin");
|
|
30
|
+
}
|
|
31
|
+
mergeBase(repoRoot, ref) {
|
|
32
|
+
return this.run(repoRoot, "merge-base", "HEAD", ref);
|
|
33
|
+
}
|
|
34
|
+
commitDistance(repoRoot, from, to) {
|
|
35
|
+
const out = this.run(repoRoot, "rev-list", "--count", `${from}..${to}`);
|
|
36
|
+
if (out === undefined)
|
|
37
|
+
return undefined;
|
|
38
|
+
const n = Number.parseInt(out, 10);
|
|
39
|
+
return Number.isNaN(n) ? undefined : n;
|
|
40
|
+
}
|
|
41
|
+
localBranches(repoRoot) {
|
|
42
|
+
const out = this.run(repoRoot, "for-each-ref", "--format=%(refname:short)", "refs/heads");
|
|
43
|
+
if (!out)
|
|
44
|
+
return [];
|
|
45
|
+
return out
|
|
46
|
+
.split("\n")
|
|
47
|
+
.map((l) => l.trim())
|
|
48
|
+
.filter(Boolean);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Run git with an argv array rather than a command string.
|
|
52
|
+
*
|
|
53
|
+
* This must not go through a shell. Git's own format specifiers contain
|
|
54
|
+
* parentheses (`--format=%(refname:short)`), and branch names may legally
|
|
55
|
+
* contain `(`, `)`, `&`, `;`, `$` and quotes — all of which a shell would
|
|
56
|
+
* interpret. Passing a string here silently broke branch listing entirely
|
|
57
|
+
* and made any branch name with a metacharacter unusable.
|
|
58
|
+
*/
|
|
59
|
+
run(cwd, ...args) {
|
|
60
|
+
try {
|
|
61
|
+
return execFileSync("git", args, {
|
|
62
|
+
cwd,
|
|
63
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
64
|
+
timeout: GitClient.TIMEOUT_MS,
|
|
65
|
+
})
|
|
66
|
+
.toString()
|
|
67
|
+
.trim();
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=GitClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitClient.js","sourceRoot":"","sources":["../../../src/infrastructure/git/GitClient.ts"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,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACnC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,aAAa,CAAC,QAAgB;QAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CACnB,QAAQ,EACR,cAAc,EACd,2BAA2B,EAC3B,YAAY,CACZ,CAAC;QACF,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,CAAC;QACpB,OAAO,GAAG;aACR,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,MAAM,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IAED;;;;;;;;OAQG;IACK,GAAG,CAAC,GAAW,EAAE,GAAG,IAAc;QACzC,IAAI,CAAC;YACJ,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE;gBAChC,GAAG;gBACH,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;gBACnC,OAAO,EAAE,SAAS,CAAC,UAAU;aAC7B,CAAC;iBACA,QAAQ,EAAE;iBACV,IAAI,EAAE,CAAC;QACV,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,SAAS,CAAC;QAClB,CAAC;IACF,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Chunk } from "../../domain/corpus/Chunk.js";
|
|
2
|
+
import { ContentHash } from "../../domain/corpus/ContentHash.js";
|
|
3
|
+
import type { ChunkQuery, ChunkRepositoryPort, ChunkText, EmbeddedChunk } from "../../domain/ports/ChunkRepositoryPort.js";
|
|
4
|
+
import type { FileManifestRepositoryPort } from "../../domain/ports/FileManifestRepositoryPort.js";
|
|
5
|
+
import type { Branch } from "../../domain/project/Branch.js";
|
|
6
|
+
import { HitList } from "../../domain/retrieval/HitList.js";
|
|
7
|
+
import { LanceTables } from "./LanceTables.js";
|
|
8
|
+
/**
|
|
9
|
+
* Embedded chunks in LanceDB.
|
|
10
|
+
*
|
|
11
|
+
* Branch scoping lives here because it is a property of how chunks are stored:
|
|
12
|
+
* they are shared across branches by content hash, so a query must intersect
|
|
13
|
+
* them with the manifest of file versions the branch actually references.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ChunkRepository implements ChunkRepositoryPort {
|
|
16
|
+
private readonly tables;
|
|
17
|
+
private readonly manifest;
|
|
18
|
+
private readonly branch;
|
|
19
|
+
constructor(tables: LanceTables, manifest: FileManifestRepositoryPort, branch: Branch);
|
|
20
|
+
add(chunks: EmbeddedChunk[]): Promise<void>;
|
|
21
|
+
search(query: ChunkQuery): Promise<HitList>;
|
|
22
|
+
/**
|
|
23
|
+
* Delete chunks for files no longer referenced by ANY branch. A path still
|
|
24
|
+
* present in another branch's manifest keeps its chunks — they are shared
|
|
25
|
+
* by content, so deleting them would blank that branch's results.
|
|
26
|
+
*/
|
|
27
|
+
deleteByFiles(filePaths: string[]): Promise<void>;
|
|
28
|
+
existingHashes(hashes: ContentHash[]): Promise<Set<string>>;
|
|
29
|
+
count(): Promise<number>;
|
|
30
|
+
hashesByFile(): Promise<Map<string, string[]>>;
|
|
31
|
+
allHashes(): Promise<Set<string>>;
|
|
32
|
+
streamTexts(batchSize?: number): AsyncGenerator<ChunkText[]>;
|
|
33
|
+
private buildPredicate;
|
|
34
|
+
private toRow;
|
|
35
|
+
private toHit;
|
|
36
|
+
/** Rebuild a domain Chunk from a stored row — used by import and dedup. */
|
|
37
|
+
static rowToChunk(row: Record<string, unknown>): Chunk;
|
|
38
|
+
}
|
|
@@ -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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AAC,IAAc,EAClB,GAAG,CAAC,OAAiB,EACrB,GAAG,CAAC,OAAiB,EACrB,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,EACnC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,QAA8B,CAAC,CAC1D,CAAC;IACH,CAAC;IAED,2EAA2E;IAC3E,MAAM,CAAC,UAAU,CAAC,GAA4B;QAC7C,OAAO,IAAI,KAAK,CAAC;YAChB,QAAQ,EAAE,IAAI,YAAY,CACzB,GAAG,CAAC,QAAkB,EACtB,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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ile } 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
|
+
}
|