lmgrep 0.1.17 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +5 -754
- 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 -33
- package/dist/index.js +32 -215
- 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/infrastructure/lancedb/NativeTuning.d.ts +1 -0
- package/dist/infrastructure/lancedb/NativeTuning.js +9 -0
- 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} +65 -41
- 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 +15 -61
- 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 -63
- package/dist/lib/build.d.ts +0 -7
- package/dist/lib/build.js +0 -284
- 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 -150
- 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 -55
- package/dist/lib/embedder.js +0 -221
- package/dist/lib/embedder.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 -47
- package/dist/lib/search-tool.js +0 -239
- package/dist/lib/search-tool.js.map +0 -1
- package/dist/lib/serve.d.ts +0 -11
- package/dist/lib/serve.js +0 -127
- package/dist/lib/serve.js.map +0 -1
- package/dist/lib/store.d.ts +0 -177
- package/dist/lib/store.js +0 -825
- package/dist/lib/store.js.map +0 -1
- package/dist/lib/types.d.ts +0 -129
- package/dist/lib/types.js +0 -13
- package/dist/lib/types.js.map +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when a search reaches a database that has no chunk table.
|
|
3
|
+
*
|
|
4
|
+
* A distinct type rather than a plain Error because the *reason* it is missing
|
|
5
|
+
* is only knowable further out — most often the configured model changed and
|
|
6
|
+
* this project's other models are sitting right beside it — and matching on a
|
|
7
|
+
* message string to detect that would break the first time the wording did.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MissingIndexError extends Error {
|
|
10
|
+
constructor(message?: string);
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when a search reaches a database that has no chunk table.
|
|
3
|
+
*
|
|
4
|
+
* A distinct type rather than a plain Error because the *reason* it is missing
|
|
5
|
+
* is only knowable further out — most often the configured model changed and
|
|
6
|
+
* this project's other models are sitting right beside it — and matching on a
|
|
7
|
+
* message string to detect that would break the first time the wording did.
|
|
8
|
+
*/
|
|
9
|
+
export class MissingIndexError extends Error {
|
|
10
|
+
constructor(message = "No index found. Run `lmgrep index` first.") {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "MissingIndexError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=MissingIndexError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MissingIndexError.js","sourceRoot":"","sources":["../../../src/domain/retrieval/MissingIndexError.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC3C,YAAY,OAAO,GAAG,2CAA2C;QAChE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IACjC,CAAC;CACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,33 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
export
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point.
|
|
3
|
+
*
|
|
4
|
+
* Composition lives in {@link LmgrepFactory}; this module only re-exports, so
|
|
5
|
+
* nothing here should ever contain logic.
|
|
6
|
+
*/
|
|
7
|
+
export type { IndexBuildOptions, IndexBuildResult, IndexingProgressEvent, } from "./application/indexing/IndexingProgress.js";
|
|
8
|
+
export { Lmgrep } from "./application/Lmgrep.js";
|
|
9
|
+
export { LmgrepFactory, type LmgrepOptions, } from "./application/LmgrepFactory.js";
|
|
10
|
+
export type { HealthState } from "./application/operations/HealthMonitor.js";
|
|
11
|
+
export type { StatusInfo } from "./application/operations/StatusService.js";
|
|
12
|
+
export type { ResearchResult } from "./application/research/ResearchAgent.js";
|
|
13
|
+
export type { SearchOptions } from "./application/search/SearchCriteria.js";
|
|
14
|
+
export type { LmgrepConfig } from "./domain/config/LmgrepConfig.js";
|
|
15
|
+
export { Chunk } from "./domain/corpus/Chunk.js";
|
|
16
|
+
export { CodeLocation } from "./domain/corpus/CodeLocation.js";
|
|
17
|
+
export { ContentHash } from "./domain/corpus/ContentHash.js";
|
|
18
|
+
export { FileVersion } from "./domain/corpus/FileVersion.js";
|
|
19
|
+
export { FileManifest, SourceFile } from "./domain/corpus/SourceFile.js";
|
|
20
|
+
export { Vector } from "./domain/corpus/Vector.js";
|
|
21
|
+
export type { ChunkerPort } from "./domain/ports/ChunkerPort.js";
|
|
22
|
+
export type { EmbedderPort } from "./domain/ports/EmbedderPort.js";
|
|
23
|
+
export type { LoggerPort } from "./domain/ports/LoggerPort.js";
|
|
24
|
+
export { Branch } from "./domain/project/Branch.js";
|
|
25
|
+
export { DatabaseLocation } from "./domain/project/DatabaseLocation.js";
|
|
26
|
+
export type { IndexMetadata } from "./domain/project/IndexMetadata.js";
|
|
27
|
+
export { ModelIdentity } from "./domain/project/ModelIdentity.js";
|
|
28
|
+
export { Project } from "./domain/project/Project.js";
|
|
29
|
+
export { ProjectId } from "./domain/project/ProjectId.js";
|
|
30
|
+
export { ProjectLocator } from "./domain/project/ProjectLocator.js";
|
|
31
|
+
export type { TraceEntry } from "./domain/research/ResearchTrace.js";
|
|
32
|
+
export { Hit } from "./domain/retrieval/Hit.js";
|
|
33
|
+
export { HitList } from "./domain/retrieval/HitList.js";
|
|
34
|
+
export { AiSdkEmbedder } from "./infrastructure/ai/AiSdkEmbedder.js";
|
|
35
|
+
export { ConfigLoader } from "./infrastructure/fs/ConfigLoader.js";
|
|
36
|
+
export { ConsoleLogger, SilentLogger } from "./infrastructure/fs/Loggers.js";
|
|
37
|
+
export { ProjectMetadataStore } from "./infrastructure/fs/ProjectMetadataStore.js";
|
|
38
|
+
export { StateDirectory } from "./infrastructure/fs/StateDirectory.js";
|
|
39
|
+
export { IndexShare } from "./infrastructure/p2p/IndexShare.js";
|
|
40
|
+
export { ShareCode } from "./infrastructure/p2p/ShareCode.js";
|
|
41
|
+
export { ProcessRegistry, type RunningProcess, } from "./infrastructure/process/ProcessRegistry.js";
|
|
42
|
+
export { TreeSitterChunker } from "./infrastructure/treesitter/TreeSitterChunker.js";
|
|
43
|
+
export { LmgrepCore } from "./presentation/mcp/LmgrepCore.js";
|
package/dist/index.js
CHANGED
|
@@ -1,216 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let queryVector = await embedder.embedQuery(query);
|
|
34
|
-
// Check model compatibility with the index
|
|
35
|
-
const dbPath = getDbPath(cwd);
|
|
36
|
-
const meta = readProjectMetadata(dbPath);
|
|
37
|
-
if (meta) {
|
|
38
|
-
// Hard error: dimension mismatch
|
|
39
|
-
if (meta.dimensions != null && queryVector.length !== meta.dimensions) {
|
|
40
|
-
throw new Error(`Dimension mismatch: index has ${meta.dimensions}-dim vectors but your model produces ${queryVector.length}-dim. ` +
|
|
41
|
-
`These embeddings are incompatible.`);
|
|
42
|
-
}
|
|
43
|
-
// Advisory: model family mismatch
|
|
44
|
-
if (meta.model) {
|
|
45
|
-
const indexFamily = extractModelFamily(meta.model);
|
|
46
|
-
const queryFamily = extractModelFamily(config.model);
|
|
47
|
-
if (indexFamily !== queryFamily) {
|
|
48
|
-
logger.info(`Warning: index was built with "${meta.model}" (${indexFamily}) ` +
|
|
49
|
-
`but searching with "${config.model}" (${queryFamily}). ` +
|
|
50
|
-
`Results may be degraded if these are different model families.`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// Subtract the --not vector to push away unwanted results
|
|
55
|
-
if (opts.not) {
|
|
56
|
-
const notVector = await embedder.embedQuery(opts.not);
|
|
57
|
-
queryVector = queryVector.map((v, i) => v - notVector[i] * 0.5);
|
|
58
|
-
}
|
|
59
|
-
// Determine which stores to search
|
|
60
|
-
const targets = resolveSearchTargets(cwd, store, opts);
|
|
61
|
-
const limit = opts.limit ?? 25;
|
|
62
|
-
// Search all targets
|
|
63
|
-
let results = [];
|
|
64
|
-
for (const target of targets) {
|
|
65
|
-
const targetResults = await target.store.search(queryVector, limit, target.filePrefix, opts.type, !target.projectRoot);
|
|
66
|
-
// Tag results from foreign projects with their root
|
|
67
|
-
if (target.projectRoot) {
|
|
68
|
-
for (const r of targetResults) {
|
|
69
|
-
r.filePath = `${target.projectRoot}/${r.filePath}`;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
results.push(...targetResults);
|
|
73
|
-
}
|
|
74
|
-
// When searching multiple targets, sort by score and trim
|
|
75
|
-
if (targets.length > 1) {
|
|
76
|
-
results.sort((a, b) => b.score - a.score);
|
|
77
|
-
results = results.slice(0, limit);
|
|
78
|
-
}
|
|
79
|
-
// Post-filter by language (file extension)
|
|
80
|
-
if (opts.language && opts.language.length > 0) {
|
|
81
|
-
const exts = new Set(opts.language.map((l) => (l.startsWith(".") ? l : `.${l}`)));
|
|
82
|
-
results = results.filter((r) => exts.has(r.filePath.slice(r.filePath.lastIndexOf("."))));
|
|
83
|
-
}
|
|
84
|
-
if (opts.minScore != null) {
|
|
85
|
-
results = results.filter((r) => r.score >= opts.minScore);
|
|
86
|
-
}
|
|
87
|
-
// Close any foreign stores we opened
|
|
88
|
-
for (const target of targets) {
|
|
89
|
-
if (target.store !== store) {
|
|
90
|
-
await target.store.close();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return results;
|
|
94
|
-
},
|
|
95
|
-
async repair(dry = false) {
|
|
96
|
-
return repair(cwd, store, dry, logger);
|
|
97
|
-
},
|
|
98
|
-
async watch() {
|
|
99
|
-
return serve(cwd, store, config, embedder, chunker, logger);
|
|
100
|
-
},
|
|
101
|
-
async status() {
|
|
102
|
-
const ancestor = findIndexedAncestor(cwd);
|
|
103
|
-
const projectRoot = ancestor ? ancestor.root : cwd;
|
|
104
|
-
const prefix = ancestor?.prefix ?? "";
|
|
105
|
-
const statusStore = projectRoot === cwd ? store : Store.forProject(projectRoot);
|
|
106
|
-
const files = await statusStore.getIndexedFiles();
|
|
107
|
-
const hashes = await statusStore.getIndexedHashes();
|
|
108
|
-
let totalChunks = 0;
|
|
109
|
-
for (const [, h] of files)
|
|
110
|
-
totalChunks += h.length;
|
|
111
|
-
// Embed once with a generic query, then reuse the vector for the
|
|
112
|
-
// smoke search — one network roundtrip covers both checks.
|
|
113
|
-
let embeddingOk = false;
|
|
114
|
-
let embeddingLatencyMs;
|
|
115
|
-
let embeddingError;
|
|
116
|
-
let searchOk = false;
|
|
117
|
-
let searchResultCount;
|
|
118
|
-
let searchLatencyMs;
|
|
119
|
-
try {
|
|
120
|
-
const embedStart = Date.now();
|
|
121
|
-
const vector = await withTimeout(embedder.embedQuery("code"), 3000);
|
|
122
|
-
embeddingLatencyMs = Date.now() - embedStart;
|
|
123
|
-
embeddingOk = true;
|
|
124
|
-
if (files.size > 0) {
|
|
125
|
-
try {
|
|
126
|
-
const searchStart = Date.now();
|
|
127
|
-
const results = await withTimeout(statusStore.search(vector, 1), 3000);
|
|
128
|
-
searchLatencyMs = Date.now() - searchStart;
|
|
129
|
-
searchResultCount = results.length;
|
|
130
|
-
searchOk = results.length > 0;
|
|
131
|
-
}
|
|
132
|
-
catch { }
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (err) {
|
|
136
|
-
embeddingError = err instanceof Error ? err.message : String(err);
|
|
137
|
-
}
|
|
138
|
-
// Read index metadata for model/dimensions info
|
|
139
|
-
const meta = readProjectMetadata(getDbPath(projectRoot));
|
|
140
|
-
return {
|
|
141
|
-
projectRoot,
|
|
142
|
-
prefix,
|
|
143
|
-
config,
|
|
144
|
-
fileCount: files.size,
|
|
145
|
-
chunkCount: totalChunks,
|
|
146
|
-
uniqueHashes: hashes.size,
|
|
147
|
-
embeddingOk,
|
|
148
|
-
embeddingLatencyMs,
|
|
149
|
-
embeddingError,
|
|
150
|
-
searchOk,
|
|
151
|
-
searchResultCount,
|
|
152
|
-
searchLatencyMs,
|
|
153
|
-
indexModel: meta?.model,
|
|
154
|
-
indexDimensions: meta?.dimensions,
|
|
155
|
-
};
|
|
156
|
-
},
|
|
157
|
-
async close() {
|
|
158
|
-
await store.close();
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
// --- Internal helpers ---
|
|
163
|
-
function withTimeout(promise, ms) {
|
|
164
|
-
return new Promise((resolve, reject) => {
|
|
165
|
-
const timer = setTimeout(() => reject(new Error(`timeout after ${ms}ms`)), ms);
|
|
166
|
-
promise.then((v) => {
|
|
167
|
-
clearTimeout(timer);
|
|
168
|
-
resolve(v);
|
|
169
|
-
}, (e) => {
|
|
170
|
-
clearTimeout(timer);
|
|
171
|
-
reject(e);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
function resolveSearchTargets(cwd, localStore, opts) {
|
|
176
|
-
// --across: search multiple projects
|
|
177
|
-
if (opts.across && opts.across.length > 0) {
|
|
178
|
-
const targets = [
|
|
179
|
-
{ store: localStore, filePrefix: opts.filePrefix },
|
|
180
|
-
];
|
|
181
|
-
for (const p of opts.across) {
|
|
182
|
-
const abs = resolve(cwd, p);
|
|
183
|
-
const { root } = resolveProject(abs);
|
|
184
|
-
targets.push({
|
|
185
|
-
store: Store.forProject(abs),
|
|
186
|
-
filePrefix: opts.filePrefix,
|
|
187
|
-
projectRoot: root,
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
return targets;
|
|
191
|
-
}
|
|
192
|
-
// --project: search a single foreign project
|
|
193
|
-
if (opts.project) {
|
|
194
|
-
const abs = resolve(cwd, opts.project);
|
|
195
|
-
const { root } = resolveProject(abs);
|
|
196
|
-
return [
|
|
197
|
-
{
|
|
198
|
-
store: Store.forProject(abs),
|
|
199
|
-
filePrefix: opts.filePrefix,
|
|
200
|
-
projectRoot: root,
|
|
201
|
-
},
|
|
202
|
-
];
|
|
203
|
-
}
|
|
204
|
-
// Default: search local project, resolving ancestor prefix
|
|
205
|
-
let filePrefix = opts.filePrefix;
|
|
206
|
-
let searchStore = localStore;
|
|
207
|
-
const ancestor = findIndexedAncestor(cwd);
|
|
208
|
-
if (ancestor?.prefix) {
|
|
209
|
-
searchStore = Store.forProject(ancestor.root);
|
|
210
|
-
filePrefix = filePrefix
|
|
211
|
-
? `${ancestor.prefix}/${filePrefix}`
|
|
212
|
-
: ancestor.prefix;
|
|
213
|
-
}
|
|
214
|
-
return [{ store: searchStore, filePrefix }];
|
|
215
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point.
|
|
3
|
+
*
|
|
4
|
+
* Composition lives in {@link LmgrepFactory}; this module only re-exports, so
|
|
5
|
+
* nothing here should ever contain logic.
|
|
6
|
+
*/
|
|
7
|
+
export { Lmgrep } from "./application/Lmgrep.js";
|
|
8
|
+
export { LmgrepFactory, } from "./application/LmgrepFactory.js";
|
|
9
|
+
export { Chunk } from "./domain/corpus/Chunk.js";
|
|
10
|
+
export { CodeLocation } from "./domain/corpus/CodeLocation.js";
|
|
11
|
+
export { ContentHash } from "./domain/corpus/ContentHash.js";
|
|
12
|
+
export { FileVersion } from "./domain/corpus/FileVersion.js";
|
|
13
|
+
export { FileManifest, SourceFile } from "./domain/corpus/SourceFile.js";
|
|
14
|
+
export { Vector } from "./domain/corpus/Vector.js";
|
|
15
|
+
export { Branch } from "./domain/project/Branch.js";
|
|
16
|
+
export { DatabaseLocation } from "./domain/project/DatabaseLocation.js";
|
|
17
|
+
export { ModelIdentity } from "./domain/project/ModelIdentity.js";
|
|
18
|
+
export { Project } from "./domain/project/Project.js";
|
|
19
|
+
export { ProjectId } from "./domain/project/ProjectId.js";
|
|
20
|
+
export { ProjectLocator } from "./domain/project/ProjectLocator.js";
|
|
21
|
+
export { Hit } from "./domain/retrieval/Hit.js";
|
|
22
|
+
export { HitList } from "./domain/retrieval/HitList.js";
|
|
23
|
+
export { AiSdkEmbedder } from "./infrastructure/ai/AiSdkEmbedder.js";
|
|
24
|
+
export { ConfigLoader } from "./infrastructure/fs/ConfigLoader.js";
|
|
25
|
+
export { ConsoleLogger, SilentLogger } from "./infrastructure/fs/Loggers.js";
|
|
26
|
+
export { ProjectMetadataStore } from "./infrastructure/fs/ProjectMetadataStore.js";
|
|
27
|
+
export { StateDirectory } from "./infrastructure/fs/StateDirectory.js";
|
|
28
|
+
export { IndexShare } from "./infrastructure/p2p/IndexShare.js";
|
|
29
|
+
export { ShareCode } from "./infrastructure/p2p/ShareCode.js";
|
|
30
|
+
export { ProcessRegistry, } from "./infrastructure/process/ProcessRegistry.js";
|
|
31
|
+
export { TreeSitterChunker } from "./infrastructure/treesitter/TreeSitterChunker.js";
|
|
32
|
+
export { LmgrepCore } from "./presentation/mcp/LmgrepCore.js";
|
|
216
33
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EACN,aAAa,GAEb,MAAM,gCAAgC,CAAC;AAMxC,OAAO,EAAE,KAA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|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { LmgrepConfig } from "../../domain/config/LmgrepConfig.js";
|
|
2
|
+
import type { ChatModelPort, ChatOutcome, CompletionRequest, ToolLoopRequest } from "../../domain/ports/ChatModelPort.js";
|
|
3
|
+
import { ProviderRegistry } from "./ProviderRegistry.js";
|
|
4
|
+
/**
|
|
5
|
+
* The generative model behind `lmgrep ask`.
|
|
6
|
+
*
|
|
7
|
+
* It defaults to the embedding provider's package and baseURL, so enabling
|
|
8
|
+
* `ask` on a local LM Studio or Ollama setup is a single config line rather
|
|
9
|
+
* than a second provider block.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AiSdkChatModel implements ChatModelPort {
|
|
12
|
+
private readonly config;
|
|
13
|
+
private readonly providers;
|
|
14
|
+
private model;
|
|
15
|
+
constructor(config: LmgrepConfig, providers?: ProviderRegistry);
|
|
16
|
+
/** Whether a chat model is configured at all — `ask` is hidden when not. */
|
|
17
|
+
get isConfigured(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Run the agentic loop, translating provider failures into outcomes.
|
|
20
|
+
*
|
|
21
|
+
* A timeout or an overflowed context is reported as `interrupted` rather
|
|
22
|
+
* than thrown: the caller still holds usable evidence and can synthesize
|
|
23
|
+
* from it, which is the difference between a slow answer and no answer.
|
|
24
|
+
*/
|
|
25
|
+
runToolLoop(request: ToolLoopRequest): Promise<ChatOutcome>;
|
|
26
|
+
complete(request: CompletionRequest): Promise<string | undefined>;
|
|
27
|
+
private resolve;
|
|
28
|
+
/** Env overrides exist so several models can be benchmarked without edits. */
|
|
29
|
+
private get modelString();
|
|
30
|
+
private get baseURL();
|
|
31
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { createProviderRegistry, generateText, stepCountIs, tool, } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ProviderFailure } from "./ProviderFailure.js";
|
|
4
|
+
import { ModelReference, ProviderRegistry } from "./ProviderRegistry.js";
|
|
5
|
+
/**
|
|
6
|
+
* The generative model behind `lmgrep ask`.
|
|
7
|
+
*
|
|
8
|
+
* It defaults to the embedding provider's package and baseURL, so enabling
|
|
9
|
+
* `ask` on a local LM Studio or Ollama setup is a single config line rather
|
|
10
|
+
* than a second provider block.
|
|
11
|
+
*/
|
|
12
|
+
export class AiSdkChatModel {
|
|
13
|
+
config;
|
|
14
|
+
providers;
|
|
15
|
+
model;
|
|
16
|
+
constructor(config, providers = new ProviderRegistry()) {
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.providers = providers;
|
|
19
|
+
}
|
|
20
|
+
/** Whether a chat model is configured at all — `ask` is hidden when not. */
|
|
21
|
+
get isConfigured() {
|
|
22
|
+
return Boolean(this.modelString);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Run the agentic loop, translating provider failures into outcomes.
|
|
26
|
+
*
|
|
27
|
+
* A timeout or an overflowed context is reported as `interrupted` rather
|
|
28
|
+
* than thrown: the caller still holds usable evidence and can synthesize
|
|
29
|
+
* from it, which is the difference between a slow answer and no answer.
|
|
30
|
+
*/
|
|
31
|
+
async runToolLoop(request) {
|
|
32
|
+
const model = await this.resolve();
|
|
33
|
+
let steps = 0;
|
|
34
|
+
const searchTool = tool({
|
|
35
|
+
description: request.toolDescription,
|
|
36
|
+
inputSchema: z.object({
|
|
37
|
+
query: z
|
|
38
|
+
.string()
|
|
39
|
+
.describe("Natural-language intent, phrased as a question."),
|
|
40
|
+
filePrefix: z
|
|
41
|
+
.string()
|
|
42
|
+
.optional()
|
|
43
|
+
.describe("Restrict to files under this path prefix."),
|
|
44
|
+
type: z
|
|
45
|
+
.array(z.string())
|
|
46
|
+
.optional()
|
|
47
|
+
.describe("Filter by AST node type (e.g. ['function_declaration'])."),
|
|
48
|
+
language: z
|
|
49
|
+
.array(z.string())
|
|
50
|
+
.optional()
|
|
51
|
+
.describe("Filter by file extension (e.g. ['.ts'])."),
|
|
52
|
+
limit: z.number().optional().describe("Max hits (default 5)."),
|
|
53
|
+
}),
|
|
54
|
+
execute: async (call) => request.onSearch(call),
|
|
55
|
+
});
|
|
56
|
+
try {
|
|
57
|
+
const result = await generateText({
|
|
58
|
+
model,
|
|
59
|
+
system: request.system,
|
|
60
|
+
prompt: request.prompt,
|
|
61
|
+
tools: { search: searchTool },
|
|
62
|
+
stopWhen: stepCountIs(request.maxSteps),
|
|
63
|
+
temperature: 0,
|
|
64
|
+
abortSignal: AbortSignal.timeout(request.timeoutMs),
|
|
65
|
+
onStepFinish: () => {
|
|
66
|
+
steps++;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
return { status: "completed", text: result.text.trim(), steps };
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
if (ProviderFailure.isAbort(err)) {
|
|
73
|
+
return { status: "interrupted", reason: "timeout", steps };
|
|
74
|
+
}
|
|
75
|
+
if (ProviderFailure.isContextOverflow(err)) {
|
|
76
|
+
return {
|
|
77
|
+
status: "interrupted",
|
|
78
|
+
reason: "context-overflow",
|
|
79
|
+
steps,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return { status: "failed", error: err, steps };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async complete(request) {
|
|
86
|
+
try {
|
|
87
|
+
const result = await generateText({
|
|
88
|
+
model: await this.resolve(),
|
|
89
|
+
system: request.system,
|
|
90
|
+
prompt: request.prompt,
|
|
91
|
+
temperature: 0,
|
|
92
|
+
abortSignal: AbortSignal.timeout(request.timeoutMs),
|
|
93
|
+
});
|
|
94
|
+
return result.text.trim() || undefined;
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
ProviderFailure.debug("completion", err);
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async resolve() {
|
|
102
|
+
if (this.model)
|
|
103
|
+
return this.model;
|
|
104
|
+
const modelString = this.modelString;
|
|
105
|
+
if (!modelString) {
|
|
106
|
+
throw new Error("No chat model configured. Set `chatModel` in your lmgrep config " +
|
|
107
|
+
"(e.g. `chatModel: lmstudio:qwen/qwen3.5-9b`) to use `lmgrep ask`.");
|
|
108
|
+
}
|
|
109
|
+
const reference = ModelReference.parse(modelString, "chatModel");
|
|
110
|
+
const instance = await this.providers.instantiate({
|
|
111
|
+
reference,
|
|
112
|
+
// Reuse the embedding provider package unless overridden — on a
|
|
113
|
+
// shared local endpoint chat and embeddings sit behind one
|
|
114
|
+
// OpenAI-compatible provider.
|
|
115
|
+
packageName: this.config.chatProvider ?? this.config.provider,
|
|
116
|
+
baseURL: this.baseURL,
|
|
117
|
+
// A bare default export ignores baseURL and would hit the cloud, so
|
|
118
|
+
// prefer the factory whenever one is configured.
|
|
119
|
+
preferFactoryWhenBaseUrlSet: true,
|
|
120
|
+
});
|
|
121
|
+
const registry = createProviderRegistry({
|
|
122
|
+
[reference.provider]: instance,
|
|
123
|
+
});
|
|
124
|
+
this.model = registry.languageModel(reference.full);
|
|
125
|
+
return this.model;
|
|
126
|
+
}
|
|
127
|
+
/** Env overrides exist so several models can be benchmarked without edits. */
|
|
128
|
+
get modelString() {
|
|
129
|
+
return process.env.LMGREP_CHAT_MODEL ?? this.config.chatModel;
|
|
130
|
+
}
|
|
131
|
+
get baseURL() {
|
|
132
|
+
return (process.env.LMGREP_CHAT_BASEURL ??
|
|
133
|
+
this.config.chatBaseURL ??
|
|
134
|
+
this.config.baseURL);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=AiSdkChatModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiSdkChatModel.js","sourceRoot":"","sources":["../../../src/infrastructure/ai/AiSdkChatModel.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EACtB,YAAY,EAEZ,WAAW,EACX,IAAI,GACJ,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,EAAE,eAAe,EAAE,MAA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C;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,8EAA8E;IAC9E,IAAY,WAAW;QACtB,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/D,CAAC;IAED,IAAY,OAAO;QAClB,OAAO,CACN,OAAO,CAAC,GAAG,CAAC,mBAAmB;YAC/B,IAAI,CAAC,MAAM,CAAC,WAAW;YACvB,IAAI,CAAC,MAAM,CAAC,OAAO,CACnB,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { LmgrepConfig } from "../../domain/config/LmgrepConfig.js";
|
|
2
|
+
import { Vector } from "../../domain/corpus/Vector.js";
|
|
3
|
+
import type { EmbedderPort } from "../../domain/ports/EmbedderPort.js";
|
|
4
|
+
import { ProviderRegistry } from "./ProviderRegistry.js";
|
|
5
|
+
/**
|
|
6
|
+
* Embeddings via the Vercel AI SDK.
|
|
7
|
+
*
|
|
8
|
+
* Documents and queries take different prefixes because asymmetric models
|
|
9
|
+
* (nomic, e5, bge) are trained to expect them; omitting them degrades recall
|
|
10
|
+
* without any visible error, so the distinction is enforced by having two
|
|
11
|
+
* methods rather than one with a flag.
|
|
12
|
+
*/
|
|
13
|
+
export declare class AiSdkEmbedder implements EmbedderPort {
|
|
14
|
+
private readonly config;
|
|
15
|
+
private readonly providers;
|
|
16
|
+
private model;
|
|
17
|
+
private dimensionsChecked;
|
|
18
|
+
constructor(config: LmgrepConfig, providers?: ProviderRegistry);
|
|
19
|
+
embedDocuments(texts: string[]): Promise<Vector[]>;
|
|
20
|
+
embedQuery(query: string): Promise<Vector>;
|
|
21
|
+
/**
|
|
22
|
+
* Check the configured width once, on the first embedding seen. A mismatch
|
|
23
|
+
* means the model is not the one the config describes, and every vector
|
|
24
|
+
* after this would be silently unusable against the index.
|
|
25
|
+
*/
|
|
26
|
+
private verifyDimensions;
|
|
27
|
+
private getModel;
|
|
28
|
+
}
|