lmgrep 0.1.18 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +226 -63
- package/completions/_lmgrep +49 -40
- package/dist/application/Lmgrep.d.ts +107 -0
- package/dist/application/Lmgrep.js +99 -0
- package/dist/application/Lmgrep.js.map +1 -0
- package/dist/application/LmgrepFactory.d.ts +40 -0
- package/dist/application/LmgrepFactory.js +155 -0
- package/dist/application/LmgrepFactory.js.map +1 -0
- package/dist/application/indexing/BranchBootstrapper.d.ts +21 -0
- package/dist/application/indexing/BranchBootstrapper.js +52 -0
- package/dist/application/indexing/BranchBootstrapper.js.map +1 -0
- package/dist/application/indexing/BranchManifestSweeper.d.ts +17 -0
- package/dist/application/indexing/BranchManifestSweeper.js +35 -0
- package/dist/application/indexing/BranchManifestSweeper.js.map +1 -0
- package/dist/application/indexing/Duration.d.ts +9 -0
- package/dist/application/indexing/Duration.js +25 -0
- package/dist/application/indexing/Duration.js.map +1 -0
- package/dist/application/indexing/EmbeddingAbortError.d.ts +11 -0
- package/dist/application/indexing/EmbeddingAbortError.js +20 -0
- package/dist/application/indexing/EmbeddingAbortError.js.map +1 -0
- package/dist/application/indexing/EmbeddingPipeline.d.ts +59 -0
- package/dist/application/indexing/EmbeddingPipeline.js +140 -0
- package/dist/application/indexing/EmbeddingPipeline.js.map +1 -0
- package/dist/application/indexing/IndexBuilder.d.ts +112 -0
- package/dist/application/indexing/IndexBuilder.js +370 -0
- package/dist/application/indexing/IndexBuilder.js.map +1 -0
- package/dist/application/indexing/IndexingProgress.d.ts +34 -0
- package/dist/application/indexing/IndexingProgress.js +2 -0
- package/dist/application/indexing/IndexingProgress.js.map +1 -0
- package/dist/application/operations/Deadline.d.ts +13 -0
- package/dist/application/operations/Deadline.js +29 -0
- package/dist/application/operations/Deadline.js.map +1 -0
- package/dist/application/operations/HealthMonitor.d.ts +58 -0
- package/dist/application/operations/HealthMonitor.js +128 -0
- package/dist/application/operations/HealthMonitor.js.map +1 -0
- package/dist/application/operations/IndexAlternatives.d.ts +35 -0
- package/dist/application/operations/IndexAlternatives.js +61 -0
- package/dist/application/operations/IndexAlternatives.js.map +1 -0
- package/dist/application/operations/IndexInventory.d.ts +69 -0
- package/dist/application/operations/IndexInventory.js +99 -0
- package/dist/application/operations/IndexInventory.js.map +1 -0
- package/dist/application/operations/StatusService.d.ts +90 -0
- package/dist/application/operations/StatusService.js +171 -0
- package/dist/application/operations/StatusService.js.map +1 -0
- package/dist/application/operations/WatchService.d.ts +67 -0
- package/dist/application/operations/WatchService.js +145 -0
- package/dist/application/operations/WatchService.js.map +1 -0
- package/dist/application/operations/WorkingTreeDiff.d.ts +19 -0
- package/dist/application/operations/WorkingTreeDiff.js +36 -0
- package/dist/application/operations/WorkingTreeDiff.js.map +1 -0
- package/dist/application/research/ResearchAgent.d.ts +68 -0
- package/dist/application/research/ResearchAgent.js +201 -0
- package/dist/application/research/ResearchAgent.js.map +1 -0
- package/dist/application/research/ResearchPrompts.d.ts +16 -0
- package/dist/application/research/ResearchPrompts.js +34 -0
- package/dist/application/research/ResearchPrompts.js.map +1 -0
- package/dist/application/search/SearchCriteria.d.ts +37 -0
- package/dist/application/search/SearchCriteria.js +48 -0
- package/dist/application/search/SearchCriteria.js.map +1 -0
- package/dist/application/search/SearchService.d.ts +36 -0
- package/dist/application/search/SearchService.js +108 -0
- package/dist/application/search/SearchService.js.map +1 -0
- package/dist/application/search/SearchTargetResolver.d.ts +56 -0
- package/dist/application/search/SearchTargetResolver.js +104 -0
- package/dist/application/search/SearchTargetResolver.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +4 -953
- package/dist/cli.js.map +1 -1
- package/dist/domain/config/ConfigSource.d.ts +16 -0
- package/dist/domain/config/ConfigSource.js +2 -0
- package/dist/domain/config/ConfigSource.js.map +1 -0
- package/dist/domain/config/LmgrepConfig.d.ts +53 -0
- package/dist/domain/config/LmgrepConfig.js +2 -0
- package/dist/domain/config/LmgrepConfig.js.map +1 -0
- package/dist/domain/corpus/Chunk.d.ts +49 -0
- package/dist/domain/corpus/Chunk.js +60 -0
- package/dist/domain/corpus/Chunk.js.map +1 -0
- package/dist/domain/corpus/CodeLocation.d.ts +18 -0
- package/dist/domain/corpus/CodeLocation.js +34 -0
- package/dist/domain/corpus/CodeLocation.js.map +1 -0
- package/dist/domain/corpus/ContentHash.d.ts +15 -0
- package/dist/domain/corpus/ContentHash.js +30 -0
- package/dist/domain/corpus/ContentHash.js.map +1 -0
- package/dist/domain/corpus/FileVersion.d.ts +31 -0
- package/dist/domain/corpus/FileVersion.js +47 -0
- package/dist/domain/corpus/FileVersion.js.map +1 -0
- package/dist/domain/corpus/SourceFile.d.ts +26 -0
- package/dist/domain/corpus/SourceFile.js +47 -0
- package/dist/domain/corpus/SourceFile.js.map +1 -0
- package/dist/domain/corpus/Vector.d.ts +37 -0
- package/dist/domain/corpus/Vector.js +96 -0
- package/dist/domain/corpus/Vector.js.map +1 -0
- package/dist/domain/ports/ChatModelPort.d.ts +57 -0
- package/dist/domain/ports/ChatModelPort.js +2 -0
- package/dist/domain/ports/ChatModelPort.js.map +1 -0
- package/dist/domain/ports/ChunkRepositoryPort.d.ts +42 -0
- package/dist/domain/ports/ChunkRepositoryPort.js +2 -0
- package/dist/domain/ports/ChunkRepositoryPort.js.map +1 -0
- package/dist/domain/ports/ChunkerPort.d.ts +5 -0
- package/dist/domain/ports/ChunkerPort.js +2 -0
- package/dist/domain/ports/ChunkerPort.js.map +1 -0
- package/dist/domain/ports/DatabaseSessionPort.d.ts +10 -0
- package/dist/domain/ports/DatabaseSessionPort.js +2 -0
- package/dist/domain/ports/DatabaseSessionPort.js.map +1 -0
- package/dist/domain/ports/EmbedderPort.d.ts +14 -0
- package/dist/domain/ports/EmbedderPort.js +2 -0
- package/dist/domain/ports/EmbedderPort.js.map +1 -0
- package/dist/domain/ports/FileManifestRepositoryPort.d.ts +32 -0
- package/dist/domain/ports/FileManifestRepositoryPort.js +2 -0
- package/dist/domain/ports/FileManifestRepositoryPort.js.map +1 -0
- package/dist/domain/ports/GitPort.d.ts +24 -0
- package/dist/domain/ports/GitPort.js +2 -0
- package/dist/domain/ports/GitPort.js.map +1 -0
- package/dist/domain/ports/IndexMaintenancePort.d.ts +58 -0
- package/dist/domain/ports/IndexMaintenancePort.js +2 -0
- package/dist/domain/ports/IndexMaintenancePort.js.map +1 -0
- package/dist/domain/ports/IndexMetadataPort.d.ts +23 -0
- package/dist/domain/ports/IndexMetadataPort.js +2 -0
- package/dist/domain/ports/IndexMetadataPort.js.map +1 -0
- package/dist/domain/ports/LockPort.d.ts +17 -0
- package/dist/domain/ports/LockPort.js +2 -0
- package/dist/domain/ports/LockPort.js.map +1 -0
- package/dist/domain/ports/LoggerPort.d.ts +5 -0
- package/dist/domain/ports/LoggerPort.js +2 -0
- package/dist/domain/ports/LoggerPort.js.map +1 -0
- package/dist/domain/ports/ProjectIndexesPort.d.ts +20 -0
- package/dist/domain/ports/ProjectIndexesPort.js +2 -0
- package/dist/domain/ports/ProjectIndexesPort.js.map +1 -0
- package/dist/domain/ports/ProjectRegistryPort.d.ts +42 -0
- package/dist/domain/ports/ProjectRegistryPort.js +2 -0
- package/dist/domain/ports/ProjectRegistryPort.js.map +1 -0
- package/dist/domain/ports/StateDirectoryPort.d.ts +29 -0
- package/dist/domain/ports/StateDirectoryPort.js +2 -0
- package/dist/domain/ports/StateDirectoryPort.js.map +1 -0
- package/dist/domain/ports/WorkspacePort.d.ts +38 -0
- package/dist/domain/ports/WorkspacePort.js +2 -0
- package/dist/domain/ports/WorkspacePort.js.map +1 -0
- package/dist/domain/project/Branch.d.ts +20 -0
- package/dist/domain/project/Branch.js +33 -0
- package/dist/domain/project/Branch.js.map +1 -0
- package/dist/domain/project/DatabaseLocation.d.ts +32 -0
- package/dist/domain/project/DatabaseLocation.js +35 -0
- package/dist/domain/project/DatabaseLocation.js.map +1 -0
- package/dist/domain/project/IndexMetadata.d.ts +17 -0
- package/dist/domain/project/IndexMetadata.js +2 -0
- package/dist/domain/project/IndexMetadata.js.map +1 -0
- package/dist/domain/project/ModelIdentity.d.ts +58 -0
- package/dist/domain/project/ModelIdentity.js +97 -0
- package/dist/domain/project/ModelIdentity.js.map +1 -0
- package/dist/domain/project/Project.d.ts +17 -0
- package/dist/domain/project/Project.js +21 -0
- package/dist/domain/project/Project.js.map +1 -0
- package/dist/domain/project/ProjectId.d.ts +28 -0
- package/dist/domain/project/ProjectId.js +58 -0
- package/dist/domain/project/ProjectId.js.map +1 -0
- package/dist/domain/project/ProjectLocator.d.ts +112 -0
- package/dist/domain/project/ProjectLocator.js +178 -0
- package/dist/domain/project/ProjectLocator.js.map +1 -0
- package/dist/domain/research/Citation.d.ts +27 -0
- package/dist/domain/research/Citation.js +43 -0
- package/dist/domain/research/Citation.js.map +1 -0
- package/dist/domain/research/EvidenceLedger.d.ts +47 -0
- package/dist/domain/research/EvidenceLedger.js +111 -0
- package/dist/domain/research/EvidenceLedger.js.map +1 -0
- package/dist/domain/research/ResearchTrace.d.ts +19 -0
- package/dist/domain/research/ResearchTrace.js +22 -0
- package/dist/domain/research/ResearchTrace.js.map +1 -0
- package/dist/domain/retrieval/Hit.d.ts +19 -0
- package/dist/domain/retrieval/Hit.js +28 -0
- package/dist/domain/retrieval/Hit.js.map +1 -0
- package/dist/domain/retrieval/HitList.d.ts +35 -0
- package/dist/domain/retrieval/HitList.js +81 -0
- package/dist/domain/retrieval/HitList.js.map +1 -0
- package/dist/domain/retrieval/MissingIndexError.d.ts +11 -0
- package/dist/domain/retrieval/MissingIndexError.js +15 -0
- package/dist/domain/retrieval/MissingIndexError.js.map +1 -0
- package/dist/index.d.ts +43 -45
- package/dist/index.js +30 -567
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/ai/AiSdkChatModel.d.ts +31 -0
- package/dist/infrastructure/ai/AiSdkChatModel.js +137 -0
- package/dist/infrastructure/ai/AiSdkChatModel.js.map +1 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.d.ts +28 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.js +79 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.js.map +1 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.d.ts +21 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.js +40 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.js.map +1 -0
- package/dist/infrastructure/ai/LmStudioProbe.d.ts +18 -0
- package/dist/infrastructure/ai/LmStudioProbe.js +49 -0
- package/dist/infrastructure/ai/LmStudioProbe.js.map +1 -0
- package/dist/infrastructure/ai/LocalModelReloader.d.ts +21 -0
- package/dist/infrastructure/ai/LocalModelReloader.js +61 -0
- package/dist/infrastructure/ai/LocalModelReloader.js.map +1 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.d.ts +36 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.js +61 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.js.map +1 -0
- package/dist/infrastructure/ai/ModelRuntime.d.ts +32 -0
- package/dist/infrastructure/ai/ModelRuntime.js +2 -0
- package/dist/infrastructure/ai/ModelRuntime.js.map +1 -0
- package/dist/infrastructure/ai/OllamaProbe.d.ts +21 -0
- package/dist/infrastructure/ai/OllamaProbe.js +69 -0
- package/dist/infrastructure/ai/OllamaProbe.js.map +1 -0
- package/dist/infrastructure/ai/ProviderFailure.d.ts +16 -0
- package/dist/infrastructure/ai/ProviderFailure.js +35 -0
- package/dist/infrastructure/ai/ProviderFailure.js.map +1 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.d.ts +13 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.js +49 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.js.map +1 -0
- package/dist/infrastructure/ai/ProviderRegistry.d.ts +37 -0
- package/dist/infrastructure/ai/ProviderRegistry.js +55 -0
- package/dist/infrastructure/ai/ProviderRegistry.js.map +1 -0
- package/dist/infrastructure/fs/ConfigLoader.d.ts +59 -0
- package/dist/infrastructure/fs/ConfigLoader.js +194 -0
- package/dist/infrastructure/fs/ConfigLoader.js.map +1 -0
- package/dist/infrastructure/fs/DatabaseLocks.d.ts +52 -0
- package/dist/infrastructure/fs/DatabaseLocks.js +92 -0
- package/dist/infrastructure/fs/DatabaseLocks.js.map +1 -0
- package/dist/infrastructure/fs/DiskUsage.d.ts +6 -0
- package/dist/infrastructure/fs/DiskUsage.js +41 -0
- package/dist/infrastructure/fs/DiskUsage.js.map +1 -0
- package/dist/infrastructure/fs/IndexableFileRules.d.ts +33 -0
- package/dist/infrastructure/fs/IndexableFileRules.js +177 -0
- package/dist/infrastructure/fs/IndexableFileRules.js.map +1 -0
- package/dist/infrastructure/fs/Loggers.d.ts +14 -0
- package/dist/infrastructure/fs/Loggers.js +18 -0
- package/dist/infrastructure/fs/Loggers.js.map +1 -0
- package/dist/infrastructure/fs/PidFileLock.d.ts +40 -0
- package/dist/infrastructure/fs/PidFileLock.js +97 -0
- package/dist/infrastructure/fs/PidFileLock.js.map +1 -0
- package/dist/infrastructure/fs/ProjectIndexes.d.ts +8 -0
- package/dist/infrastructure/fs/ProjectIndexes.js +35 -0
- package/dist/infrastructure/fs/ProjectIndexes.js.map +1 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.d.ts +42 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.js +86 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.js.map +1 -0
- package/dist/infrastructure/fs/ProjectRegistry.d.ts +25 -0
- package/dist/infrastructure/fs/ProjectRegistry.js +83 -0
- package/dist/infrastructure/fs/ProjectRegistry.js.map +1 -0
- package/dist/infrastructure/fs/StateDirectory.d.ts +28 -0
- package/dist/infrastructure/fs/StateDirectory.js +71 -0
- package/dist/infrastructure/fs/StateDirectory.js.map +1 -0
- package/dist/infrastructure/fs/Workspace.d.ts +25 -0
- package/dist/infrastructure/fs/Workspace.js +90 -0
- package/dist/infrastructure/fs/Workspace.js.map +1 -0
- package/dist/infrastructure/git/GitClient.d.ts +34 -0
- package/dist/infrastructure/git/GitClient.js +74 -0
- package/dist/infrastructure/git/GitClient.js.map +1 -0
- package/dist/infrastructure/lancedb/ChunkRepository.d.ts +38 -0
- package/dist/infrastructure/lancedb/ChunkRepository.js +166 -0
- package/dist/infrastructure/lancedb/ChunkRepository.js.map +1 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.d.ts +22 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.js +74 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.js.map +1 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.d.ts +34 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.js +137 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.js.map +1 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.d.ts +53 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.js +227 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.js.map +1 -0
- package/dist/infrastructure/lancedb/LanceTables.d.ts +67 -0
- package/dist/infrastructure/lancedb/LanceTables.js +159 -0
- package/dist/infrastructure/lancedb/LanceTables.js.map +1 -0
- package/dist/{lib/native-tuning.js → infrastructure/lancedb/NativeTuning.js} +1 -1
- package/dist/infrastructure/lancedb/NativeTuning.js.map +1 -0
- package/dist/infrastructure/lancedb/RowReplication.d.ts +27 -0
- package/dist/infrastructure/lancedb/RowReplication.js +82 -0
- package/dist/infrastructure/lancedb/RowReplication.js.map +1 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.d.ts +60 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.js +72 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.js.map +1 -0
- package/dist/infrastructure/p2p/IndexShare.d.ts +45 -0
- package/dist/infrastructure/p2p/IndexShare.js +160 -0
- package/dist/infrastructure/p2p/IndexShare.js.map +1 -0
- package/dist/infrastructure/p2p/PeerSwarm.d.ts +16 -0
- package/dist/infrastructure/p2p/PeerSwarm.js +41 -0
- package/dist/infrastructure/p2p/PeerSwarm.js.map +1 -0
- package/dist/infrastructure/p2p/SecureChannel.d.ts +60 -0
- package/dist/infrastructure/p2p/SecureChannel.js +71 -0
- package/dist/infrastructure/p2p/SecureChannel.js.map +1 -0
- package/dist/infrastructure/p2p/ShareCode.d.ts +25 -0
- package/dist/infrastructure/p2p/ShareCode.js +304 -0
- package/dist/infrastructure/p2p/ShareCode.js.map +1 -0
- package/dist/infrastructure/process/ProcessRegistry.d.ts +50 -0
- package/dist/infrastructure/process/ProcessRegistry.js +109 -0
- package/dist/infrastructure/process/ProcessRegistry.js.map +1 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.d.ts +45 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.js +159 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.js.map +1 -0
- package/dist/infrastructure/treesitter/LanguageCatalog.d.ts +30 -0
- package/dist/{lib/chunker/languages.js → infrastructure/treesitter/LanguageCatalog.js} +34 -29
- package/dist/infrastructure/treesitter/LanguageCatalog.js.map +1 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.d.ts +15 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.js +42 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.js.map +1 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.d.ts +42 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.js +163 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.js.map +1 -0
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +14 -72
- package/dist/mcp.js.map +1 -1
- package/dist/presentation/cli/Cli.d.ts +31 -0
- package/dist/presentation/cli/Cli.js +120 -0
- package/dist/presentation/cli/Cli.js.map +1 -0
- package/dist/presentation/cli/CliOptions.d.ts +18 -0
- package/dist/presentation/cli/CliOptions.js +25 -0
- package/dist/presentation/cli/CliOptions.js.map +1 -0
- package/dist/presentation/cli/CommandContext.d.ts +50 -0
- package/dist/presentation/cli/CommandContext.js +88 -0
- package/dist/presentation/cli/CommandContext.js.map +1 -0
- package/dist/presentation/cli/ConfigTemplate.d.ts +31 -0
- package/dist/presentation/cli/ConfigTemplate.js +83 -0
- package/dist/presentation/cli/ConfigTemplate.js.map +1 -0
- package/dist/presentation/cli/Renderer.d.ts +90 -0
- package/dist/presentation/cli/Renderer.js +290 -0
- package/dist/presentation/cli/Renderer.js.map +1 -0
- package/dist/presentation/cli/commands/AskCommand.d.ts +14 -0
- package/dist/presentation/cli/commands/AskCommand.js +48 -0
- package/dist/presentation/cli/commands/AskCommand.js.map +1 -0
- package/dist/presentation/cli/commands/CompletionsCommand.d.ts +18 -0
- package/dist/presentation/cli/commands/CompletionsCommand.js +96 -0
- package/dist/presentation/cli/commands/CompletionsCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ConfigCommands.d.ts +55 -0
- package/dist/presentation/cli/commands/ConfigCommands.js +204 -0
- package/dist/presentation/cli/commands/ConfigCommands.js.map +1 -0
- package/dist/presentation/cli/commands/IndexCommand.d.ts +18 -0
- package/dist/presentation/cli/commands/IndexCommand.js +54 -0
- package/dist/presentation/cli/commands/IndexCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ProjectsCommand.d.ts +48 -0
- package/dist/presentation/cli/commands/ProjectsCommand.js +240 -0
- package/dist/presentation/cli/commands/ProjectsCommand.js.map +1 -0
- package/dist/presentation/cli/commands/SearchCommand.d.ts +19 -0
- package/dist/presentation/cli/commands/SearchCommand.js +55 -0
- package/dist/presentation/cli/commands/SearchCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ServerCommands.d.ts +13 -0
- package/dist/presentation/cli/commands/ServerCommands.js +40 -0
- package/dist/presentation/cli/commands/ServerCommands.js.map +1 -0
- package/dist/presentation/cli/commands/ShareCommands.d.ts +22 -0
- package/dist/presentation/cli/commands/ShareCommands.js +134 -0
- package/dist/presentation/cli/commands/ShareCommands.js.map +1 -0
- package/dist/presentation/cli/commands/StatusCommand.d.ts +15 -0
- package/dist/presentation/cli/commands/StatusCommand.js +53 -0
- package/dist/presentation/cli/commands/StatusCommand.js.map +1 -0
- package/dist/presentation/mcp/HitFormatter.d.ts +17 -0
- package/dist/presentation/mcp/HitFormatter.js +42 -0
- package/dist/presentation/mcp/HitFormatter.js.map +1 -0
- package/dist/presentation/mcp/IndexWatchController.d.ts +17 -0
- package/dist/presentation/mcp/IndexWatchController.js +31 -0
- package/dist/presentation/mcp/IndexWatchController.js.map +1 -0
- package/dist/presentation/mcp/LmgrepCore.d.ts +66 -0
- package/dist/presentation/mcp/LmgrepCore.js +178 -0
- package/dist/presentation/mcp/LmgrepCore.js.map +1 -0
- package/dist/presentation/mcp/McpServer.d.ts +18 -0
- package/dist/presentation/mcp/McpServer.js +63 -0
- package/dist/presentation/mcp/McpServer.js.map +1 -0
- package/dist/presentation/mcp/ToolDescriptions.d.ts +40 -0
- package/dist/presentation/mcp/ToolDescriptions.js +85 -0
- package/dist/presentation/mcp/ToolDescriptions.js.map +1 -0
- package/package.json +84 -89
- package/dist/lib/build.d.ts +0 -21
- package/dist/lib/build.js +0 -374
- package/dist/lib/build.js.map +0 -1
- package/dist/lib/chunker/context.d.ts +0 -21
- package/dist/lib/chunker/context.js +0 -131
- package/dist/lib/chunker/context.js.map +0 -1
- package/dist/lib/chunker/index.d.ts +0 -7
- package/dist/lib/chunker/index.js +0 -209
- package/dist/lib/chunker/index.js.map +0 -1
- package/dist/lib/chunker/languages.d.ts +0 -15
- package/dist/lib/chunker/languages.js.map +0 -1
- package/dist/lib/config.d.ts +0 -12
- package/dist/lib/config.js +0 -83
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/embedder.d.ts +0 -65
- package/dist/lib/embedder.js +0 -236
- package/dist/lib/embedder.js.map +0 -1
- package/dist/lib/facet-session.d.ts +0 -44
- package/dist/lib/facet-session.js +0 -125
- package/dist/lib/facet-session.js.map +0 -1
- package/dist/lib/native-tuning.js.map +0 -1
- package/dist/lib/p2p.d.ts +0 -32
- package/dist/lib/p2p.js +0 -281
- package/dist/lib/p2p.js.map +0 -1
- package/dist/lib/providers.d.ts +0 -1
- package/dist/lib/providers.js +0 -41
- package/dist/lib/providers.js.map +0 -1
- package/dist/lib/repair.d.ts +0 -10
- package/dist/lib/repair.js +0 -57
- package/dist/lib/repair.js.map +0 -1
- package/dist/lib/scanner.d.ts +0 -34
- package/dist/lib/scanner.js +0 -242
- package/dist/lib/scanner.js.map +0 -1
- package/dist/lib/search-tool.d.ts +0 -55
- package/dist/lib/search-tool.js +0 -319
- package/dist/lib/search-tool.js.map +0 -1
- package/dist/lib/serve.d.ts +0 -11
- package/dist/lib/serve.js +0 -144
- package/dist/lib/serve.js.map +0 -1
- package/dist/lib/store.d.ts +0 -252
- package/dist/lib/store.js +0 -1216
- package/dist/lib/store.js.map +0 -1
- package/dist/lib/types.d.ts +0 -194
- package/dist/lib/types.js +0 -13
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/vocab.d.ts +0 -20
- package/dist/lib/vocab.js +0 -275
- package/dist/lib/vocab.js.map +0 -1
- /package/dist/{lib/native-tuning.d.ts → infrastructure/lancedb/NativeTuning.d.ts} +0 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname } from "node:path";
|
|
4
|
+
import { ModelIdentity } from "../../../domain/project/ModelIdentity.js";
|
|
5
|
+
import { EmbeddingPrefixes } from "../../../infrastructure/ai/EmbeddingPrefixes.js";
|
|
6
|
+
import { LocalRuntimeDetector } from "../../../infrastructure/ai/LocalRuntimeDetector.js";
|
|
7
|
+
import { ConfigLoader } from "../../../infrastructure/fs/ConfigLoader.js";
|
|
8
|
+
import { ConfigTemplate } from "../ConfigTemplate.js";
|
|
9
|
+
/**
|
|
10
|
+
* `init` and `config` — getting a working configuration.
|
|
11
|
+
*
|
|
12
|
+
* Both write exactly one file: the machine config. Which model to embed with
|
|
13
|
+
* describes this computer, not any repository, so there is one place it can
|
|
14
|
+
* live and one file to edit when it is wrong.
|
|
15
|
+
*
|
|
16
|
+
* `init` no longer has to reason about which model an existing index was built
|
|
17
|
+
* with. Indexes are stored per model, so choosing a different one selects a
|
|
18
|
+
* different database rather than corrupting the meaning of an existing one —
|
|
19
|
+
* an entire class of "you must pick a compatible model" logic that stopped
|
|
20
|
+
* being necessary the moment the storage layout changed.
|
|
21
|
+
*/
|
|
22
|
+
export class ConfigCommands {
|
|
23
|
+
context;
|
|
24
|
+
constructor(context) {
|
|
25
|
+
this.context = context;
|
|
26
|
+
}
|
|
27
|
+
register(program) {
|
|
28
|
+
this.registerInit(program);
|
|
29
|
+
this.registerConfig(program);
|
|
30
|
+
}
|
|
31
|
+
registerInit(program) {
|
|
32
|
+
program
|
|
33
|
+
.command("init")
|
|
34
|
+
.description("Detect your local models and write the machine config")
|
|
35
|
+
.option("--force", "Overwrite the existing config")
|
|
36
|
+
.action((options) => this.runInit(options));
|
|
37
|
+
}
|
|
38
|
+
async runInit(options) {
|
|
39
|
+
const { renderer } = this.context;
|
|
40
|
+
const loader = new ConfigLoader();
|
|
41
|
+
const configPath = loader.globalConfigPath();
|
|
42
|
+
if (existsSync(configPath) && !options.force) {
|
|
43
|
+
renderer.error(`Config already exists at ${configPath}. Use --force to re-detect, or \`lmgrep config\` to edit.`);
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// The config already at this path is an explicit prior choice.
|
|
48
|
+
const previous = loader.readFile(configPath);
|
|
49
|
+
const runtime = await new LocalRuntimeDetector().detectBest();
|
|
50
|
+
if (!runtime) {
|
|
51
|
+
this.reportNoRuntime();
|
|
52
|
+
this.write(configPath, ConfigTemplate.render());
|
|
53
|
+
renderer.line(`\nWrote ${configPath} (set a model before indexing)`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
renderer.line(`Found ${runtime.label}.`);
|
|
57
|
+
const model = this.keepConfigured(runtime, previous?.model, "embedding") ??
|
|
58
|
+
this.selectEmbeddingModel(runtime);
|
|
59
|
+
const chatModel = this.keepConfigured(runtime, previous?.chatModel, "chat") ??
|
|
60
|
+
this.selectChatModel(runtime);
|
|
61
|
+
this.write(configPath, ConfigTemplate.render({
|
|
62
|
+
model: model ? `${runtime.providerId}:${model}` : undefined,
|
|
63
|
+
baseURL: model ? runtime.baseURL : undefined,
|
|
64
|
+
providerPackage: model ? runtime.providerPackage : undefined,
|
|
65
|
+
local: model ? true : undefined,
|
|
66
|
+
chatModel: chatModel ? `${runtime.providerId}:${chatModel}` : undefined,
|
|
67
|
+
prefixes: this.prefixesFor(model, previous),
|
|
68
|
+
// Carried through rather than regenerated: this is tuning the
|
|
69
|
+
// user chose, and init has no better answer than they did.
|
|
70
|
+
batchSize: previous?.batchSize,
|
|
71
|
+
maxTokens: previous?.maxTokens,
|
|
72
|
+
dimensions: previous?.dimensions,
|
|
73
|
+
}));
|
|
74
|
+
renderer.line(`Wrote ${configPath}`);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Keep the model the config already names, when the runtime still offers it.
|
|
78
|
+
*
|
|
79
|
+
* Detection reads whatever the server lists first or happens to have
|
|
80
|
+
* loaded, and both move — LM Studio reorders by recency and unloads when
|
|
81
|
+
* idle. A model written in the config is a decision; re-deriving one from
|
|
82
|
+
* volatile state would silently swap it.
|
|
83
|
+
*/
|
|
84
|
+
keepConfigured(runtime, configured, kind) {
|
|
85
|
+
if (!configured)
|
|
86
|
+
return undefined;
|
|
87
|
+
const reference = ModelIdentity.of(configured);
|
|
88
|
+
if (reference.provider !== runtime.providerId)
|
|
89
|
+
return undefined;
|
|
90
|
+
if (!runtime.models.some((m) => m.id === reference.family)) {
|
|
91
|
+
this.context.renderer.line(`Configured ${kind} model "${reference.family}" is no longer available in ${runtime.label}.`);
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
this.context.renderer.line(`Keeping configured ${kind} model: ${reference.family}`);
|
|
95
|
+
return reference.family;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Prefixes to write: the ones already configured win, since they may be
|
|
99
|
+
* hand-tuned for a model this table knows nothing about, and an empty
|
|
100
|
+
* document prefix is a deliberate setting rather than an absent one.
|
|
101
|
+
*/
|
|
102
|
+
prefixesFor(model, previous) {
|
|
103
|
+
if (previous?.queryPrefix !== undefined) {
|
|
104
|
+
return {
|
|
105
|
+
query: previous.queryPrefix,
|
|
106
|
+
document: previous.documentPrefix ?? "",
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return model ? EmbeddingPrefixes.forModel(model) : undefined;
|
|
110
|
+
}
|
|
111
|
+
selectEmbeddingModel(runtime) {
|
|
112
|
+
const { renderer } = this.context;
|
|
113
|
+
const embedders = LocalRuntimeDetector.embeddingModels(runtime);
|
|
114
|
+
// Runtimes that do not type their models still list them; treat the
|
|
115
|
+
// untyped ones as last-resort candidates.
|
|
116
|
+
const candidates = [
|
|
117
|
+
...embedders,
|
|
118
|
+
...LocalRuntimeDetector.untypedModels(runtime),
|
|
119
|
+
];
|
|
120
|
+
const picked = embedders[0] ?? candidates[0];
|
|
121
|
+
if (!picked) {
|
|
122
|
+
renderer.line(`\nNo models available in ${runtime.label}.`);
|
|
123
|
+
renderer.line("Install an embedding model (e.g. nomic-embed-text), then run `lmgrep init` again.");
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
renderer.line(`Using embedding model: ${picked.id}${picked.loaded ? " (loaded)" : ""}`);
|
|
127
|
+
if (picked.kind !== "embedding") {
|
|
128
|
+
renderer.line(" (this model's type could not be confirmed — check it is an embedder)");
|
|
129
|
+
}
|
|
130
|
+
this.reportAlternatives(candidates, picked.id);
|
|
131
|
+
const prefixes = EmbeddingPrefixes.forModel(picked.id);
|
|
132
|
+
if (prefixes) {
|
|
133
|
+
renderer.line(` ${prefixes.family} is asymmetric — writing its required prefixes`);
|
|
134
|
+
}
|
|
135
|
+
return picked.id;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Pick a model for `ask`, but only one the runtime typed as a chat model.
|
|
139
|
+
* Guessing here surfaces as a confusing failure much later, at answer time.
|
|
140
|
+
*/
|
|
141
|
+
selectChatModel(runtime) {
|
|
142
|
+
const [picked] = LocalRuntimeDetector.chatModels(runtime);
|
|
143
|
+
if (!picked)
|
|
144
|
+
return undefined;
|
|
145
|
+
this.context.renderer.line(`Using chat model for \`ask\`: ${picked.id}${picked.loaded ? " (loaded)" : ""}`);
|
|
146
|
+
return picked.id;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Name the models not chosen.
|
|
150
|
+
*
|
|
151
|
+
* The pick is a guess whenever nothing is loaded, and switching means
|
|
152
|
+
* editing one config line — but only if the user knows what else was
|
|
153
|
+
* there. Switching is now cheap and reversible, since each model keeps its
|
|
154
|
+
* own index, but it still costs a re-embed the first time.
|
|
155
|
+
*/
|
|
156
|
+
reportAlternatives(candidates, chosen) {
|
|
157
|
+
const others = candidates.filter((m) => m.id !== chosen);
|
|
158
|
+
if (others.length === 0)
|
|
159
|
+
return;
|
|
160
|
+
this.context.renderer.line(` Also available: ${others.map((m) => m.id).join(", ")}`);
|
|
161
|
+
this.context.renderer.line(" Change `model` in the config to switch.");
|
|
162
|
+
}
|
|
163
|
+
reportNoRuntime() {
|
|
164
|
+
const { renderer } = this.context;
|
|
165
|
+
renderer.line("No local embedding server detected.\n");
|
|
166
|
+
renderer.line("Start one of:");
|
|
167
|
+
renderer.line(" Ollama curl -fsSL https://ollama.com/install.sh | sh");
|
|
168
|
+
renderer.line(" LM Studio https://lmstudio.ai — enable the local server");
|
|
169
|
+
renderer.line("");
|
|
170
|
+
renderer.line("Then run `lmgrep init` again to auto-configure, or edit the config by hand.");
|
|
171
|
+
}
|
|
172
|
+
write(configPath, contents) {
|
|
173
|
+
mkdirSync(dirname(configPath), { recursive: true });
|
|
174
|
+
writeFileSync(configPath, contents);
|
|
175
|
+
}
|
|
176
|
+
registerConfig(program) {
|
|
177
|
+
program
|
|
178
|
+
.command("config")
|
|
179
|
+
.description("Open the machine config in your editor")
|
|
180
|
+
.action(() => {
|
|
181
|
+
const { renderer } = this.context;
|
|
182
|
+
const configPath = new ConfigLoader().globalConfigPath();
|
|
183
|
+
if (!existsSync(configPath)) {
|
|
184
|
+
renderer.error(`No config found at ${configPath}. Run \`lmgrep init\` first.`);
|
|
185
|
+
process.exitCode = 1;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const editorCommand = process.env.VISUAL ?? process.env.EDITOR ?? "vi";
|
|
189
|
+
renderer.line(`Opening ${configPath}`);
|
|
190
|
+
// $EDITOR may carry flags ("code -w"), so split those off — but
|
|
191
|
+
// pass the path as its own argv entry, or a directory with
|
|
192
|
+
// spaces (macOS "Application Support") gets re-split.
|
|
193
|
+
const [editor, ...args] = editorCommand.trim().split(/\s+/);
|
|
194
|
+
const result = spawnSync(editor, [...args, configPath], {
|
|
195
|
+
stdio: "inherit",
|
|
196
|
+
});
|
|
197
|
+
if (result.error || (result.status != null && result.status !== 0)) {
|
|
198
|
+
renderer.error(`Could not open editor "${editorCommand}". Set $EDITOR or $VISUAL.`);
|
|
199
|
+
process.exitCode = 1;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=ConfigCommands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigCommands.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/ConfigCommands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AACpF,OAAO,EAAE,oBA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AC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;gBACpE,QAAQ,CAAC,KAAK,CACb,0BAA0B,aAAa,4BAA4B,CACnE,CAAC;gBACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACtB,CAAC;QACF,CAAC,CAAC,CAAC;IACL,CAAC;CACD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { CommandContext } from "../CommandContext.js";
|
|
3
|
+
/**
|
|
4
|
+
* `lmgrep index` — adopt a project, and keep it current.
|
|
5
|
+
*
|
|
6
|
+
* This is the one moment a user consents to lmgrep reading a whole repository
|
|
7
|
+
* and spending time embedding it, which is why it stays an explicit command
|
|
8
|
+
* rather than something a search triggers. Everything that used to be a
|
|
9
|
+
* separate chore afterwards — reconciling the manifest, dropping duplicate
|
|
10
|
+
* rows, compacting fragments, training the vector index — happens here, at the
|
|
11
|
+
* one moment someone is already waiting and watching.
|
|
12
|
+
*/
|
|
13
|
+
export declare class IndexCommand {
|
|
14
|
+
private readonly context;
|
|
15
|
+
constructor(context: CommandContext);
|
|
16
|
+
register(program: Command): void;
|
|
17
|
+
private run;
|
|
18
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CliOptions } from "../CliOptions.js";
|
|
2
|
+
/**
|
|
3
|
+
* `lmgrep index` — adopt a project, and keep it current.
|
|
4
|
+
*
|
|
5
|
+
* This is the one moment a user consents to lmgrep reading a whole repository
|
|
6
|
+
* and spending time embedding it, which is why it stays an explicit command
|
|
7
|
+
* rather than something a search triggers. Everything that used to be a
|
|
8
|
+
* separate chore afterwards — reconciling the manifest, dropping duplicate
|
|
9
|
+
* rows, compacting fragments, training the vector index — happens here, at the
|
|
10
|
+
* one moment someone is already waiting and watching.
|
|
11
|
+
*/
|
|
12
|
+
export class IndexCommand {
|
|
13
|
+
context;
|
|
14
|
+
constructor(context) {
|
|
15
|
+
this.context = context;
|
|
16
|
+
}
|
|
17
|
+
register(program) {
|
|
18
|
+
CliOptions.target(program
|
|
19
|
+
.command("index")
|
|
20
|
+
.description("Index this project for semantic search")
|
|
21
|
+
.option("-r, --reset", "Discard the index and rebuild from scratch")
|
|
22
|
+
.option("-v, --verbose", "Show file-by-file progress")
|
|
23
|
+
.option("-s, --since <duration>", "Only consider files modified within duration (e.g. 10m, 2h, 1d)")
|
|
24
|
+
.option("-d, --dry", "Report what would be indexed, and stop")).action((options) => this.run(options));
|
|
25
|
+
}
|
|
26
|
+
async run(options) {
|
|
27
|
+
await this.context.withLmgrep(options, async (lmgrep) => {
|
|
28
|
+
// Said before the work starts, not after: embedding a repository
|
|
29
|
+
// with a newly configured model can take a long time, and someone
|
|
30
|
+
// who only meant to try a model out should get the chance to put
|
|
31
|
+
// the old one back instead of watching it run.
|
|
32
|
+
this.context.renderer.newModelNotice(lmgrep.alternatives.others());
|
|
33
|
+
const result = await lmgrep.build({
|
|
34
|
+
reset: options.reset,
|
|
35
|
+
verbose: options.verbose,
|
|
36
|
+
since: options.since,
|
|
37
|
+
dry: options.dry,
|
|
38
|
+
// A foreground command the user is watching, so it is the right
|
|
39
|
+
// place to pay the one-time ANN training cost.
|
|
40
|
+
createIndex: true,
|
|
41
|
+
});
|
|
42
|
+
if (options.dry)
|
|
43
|
+
return;
|
|
44
|
+
// Only after a run that changed something: deduplication reads
|
|
45
|
+
// every row, and paying that on `lmgrep index` over an unchanged
|
|
46
|
+
// repository would make the no-op case the slow one.
|
|
47
|
+
if (result.succeeded > 0 || result.removed > 0) {
|
|
48
|
+
this.context.renderer.maintenance(await lmgrep.tidy());
|
|
49
|
+
}
|
|
50
|
+
this.context.renderer.line(`\nIndex: ${lmgrep.location.path}`);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=IndexCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexCommand.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/IndexCommand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AC/D,iEAAiE;YACjE,qDAAqD;YACrD,IAAI,MAAM,CAAC,SAAS,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;gBAChD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACxD,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { CommandContext } from "../CommandContext.js";
|
|
3
|
+
/**
|
|
4
|
+
* `lmgrep projects` — every index on this machine, and what to do about it.
|
|
5
|
+
*
|
|
6
|
+
* This is the answer to the state lmgrep used to accumulate silently. An index
|
|
7
|
+
* now lives inside the repository it describes, so deleting the clone deletes
|
|
8
|
+
* the index; but installs that predate that still hold databases in the state
|
|
9
|
+
* directory, pointing at working trees that may be long gone. `adopt` moves
|
|
10
|
+
* one into its repository without re-embedding, `rm` deletes one, and `gc`
|
|
11
|
+
* removes the ones whose project no longer exists.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ProjectsCommand {
|
|
14
|
+
private readonly context;
|
|
15
|
+
private readonly state;
|
|
16
|
+
private readonly metadata;
|
|
17
|
+
private readonly registry;
|
|
18
|
+
constructor(context: CommandContext);
|
|
19
|
+
register(program: Command): void;
|
|
20
|
+
private list;
|
|
21
|
+
/**
|
|
22
|
+
* Move a legacy database into its repository.
|
|
23
|
+
*
|
|
24
|
+
* Worth doing rather than re-indexing because the expensive part of an
|
|
25
|
+
* index is the embedding, not the storage — a large corpus is minutes of
|
|
26
|
+
* model time to rebuild and a rename to move. The destination is derived
|
|
27
|
+
* from the model the database *was built with*, not the one currently
|
|
28
|
+
* configured, so it lands where searches with that model will look.
|
|
29
|
+
*/
|
|
30
|
+
private adopt;
|
|
31
|
+
private remove;
|
|
32
|
+
/**
|
|
33
|
+
* Delete indexes whose project is gone.
|
|
34
|
+
*
|
|
35
|
+
* "Records no project" is excluded unless asked for. It is a recursive
|
|
36
|
+
* delete, and an index with no metadata is not evidence that its project
|
|
37
|
+
* vanished — only that nothing was written down about it. Treating the two
|
|
38
|
+
* as one would have made `gc` destroy far more than it claimed to.
|
|
39
|
+
*/
|
|
40
|
+
private collect;
|
|
41
|
+
/** Whether a legacy entry describes the project at `cwd`. */
|
|
42
|
+
private sameProject;
|
|
43
|
+
/** Rename when possible; copy across filesystems, which repos often are. */
|
|
44
|
+
private move;
|
|
45
|
+
private inventory;
|
|
46
|
+
private locator;
|
|
47
|
+
private confirm;
|
|
48
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, renameSync, rmSync } from "node:fs";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { createInterface } from "node:readline";
|
|
4
|
+
import { IndexInventory, } from "../../../application/operations/IndexInventory.js";
|
|
5
|
+
import { ModelIdentity } from "../../../domain/project/ModelIdentity.js";
|
|
6
|
+
import { ProjectLocator } from "../../../domain/project/ProjectLocator.js";
|
|
7
|
+
import { ConfigLoader } from "../../../infrastructure/fs/ConfigLoader.js";
|
|
8
|
+
import { DiskUsage } from "../../../infrastructure/fs/DiskUsage.js";
|
|
9
|
+
import { ProjectMetadataStore } from "../../../infrastructure/fs/ProjectMetadataStore.js";
|
|
10
|
+
import { ProjectRegistry } from "../../../infrastructure/fs/ProjectRegistry.js";
|
|
11
|
+
import { StateDirectory } from "../../../infrastructure/fs/StateDirectory.js";
|
|
12
|
+
import { GitClient } from "../../../infrastructure/git/GitClient.js";
|
|
13
|
+
/**
|
|
14
|
+
* `lmgrep projects` — every index on this machine, and what to do about it.
|
|
15
|
+
*
|
|
16
|
+
* This is the answer to the state lmgrep used to accumulate silently. An index
|
|
17
|
+
* now lives inside the repository it describes, so deleting the clone deletes
|
|
18
|
+
* the index; but installs that predate that still hold databases in the state
|
|
19
|
+
* directory, pointing at working trees that may be long gone. `adopt` moves
|
|
20
|
+
* one into its repository without re-embedding, `rm` deletes one, and `gc`
|
|
21
|
+
* removes the ones whose project no longer exists.
|
|
22
|
+
*/
|
|
23
|
+
export class ProjectsCommand {
|
|
24
|
+
context;
|
|
25
|
+
state = new StateDirectory();
|
|
26
|
+
metadata = new ProjectMetadataStore();
|
|
27
|
+
registry = new ProjectRegistry(this.state);
|
|
28
|
+
constructor(context) {
|
|
29
|
+
this.context = context;
|
|
30
|
+
}
|
|
31
|
+
register(program) {
|
|
32
|
+
const projects = program
|
|
33
|
+
.command("projects")
|
|
34
|
+
.description("List indexes on this machine, and reclaim their space");
|
|
35
|
+
projects
|
|
36
|
+
.command("list", { isDefault: true })
|
|
37
|
+
.description("Show every index, largest first")
|
|
38
|
+
.option("--json", "Print the inventory as JSON")
|
|
39
|
+
.action((options) => this.list(options));
|
|
40
|
+
projects
|
|
41
|
+
.command("adopt")
|
|
42
|
+
.description("Move this project's index from the state directory into the repository")
|
|
43
|
+
.action(() => this.adopt());
|
|
44
|
+
projects
|
|
45
|
+
.command("rm [database]")
|
|
46
|
+
.description("Delete an index — this project's, or the database path given")
|
|
47
|
+
.option("--force", "Skip confirmation")
|
|
48
|
+
.action((database, options) => this.remove(database, options));
|
|
49
|
+
projects
|
|
50
|
+
.command("gc")
|
|
51
|
+
.description("Delete indexes whose project no longer exists, and forget dead pointers")
|
|
52
|
+
.option("--force", "Skip confirmation")
|
|
53
|
+
.option("-d, --dry", "Show what would be deleted, and stop")
|
|
54
|
+
.option("--unknown", "Also delete indexes that record no project at all (usually interrupted runs)")
|
|
55
|
+
.action((options) => this.collect(options));
|
|
56
|
+
}
|
|
57
|
+
list(options) {
|
|
58
|
+
const inventory = this.inventory().collect();
|
|
59
|
+
if (options.json) {
|
|
60
|
+
this.context.renderer.json(inventory);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.context.renderer.inventory(inventory);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Move a legacy database into its repository.
|
|
67
|
+
*
|
|
68
|
+
* Worth doing rather than re-indexing because the expensive part of an
|
|
69
|
+
* index is the embedding, not the storage — a large corpus is minutes of
|
|
70
|
+
* model time to rebuild and a rename to move. The destination is derived
|
|
71
|
+
* from the model the database *was built with*, not the one currently
|
|
72
|
+
* configured, so it lands where searches with that model will look.
|
|
73
|
+
*/
|
|
74
|
+
async adopt() {
|
|
75
|
+
const { renderer, cwd } = this.context;
|
|
76
|
+
const locator = this.locator();
|
|
77
|
+
const home = locator.indexHomeFor(cwd);
|
|
78
|
+
const candidates = this.inventory()
|
|
79
|
+
.collect()
|
|
80
|
+
.entries.filter((e) => e.kind === "legacy" && e.root && this.sameProject(e, cwd));
|
|
81
|
+
if (candidates.length === 0) {
|
|
82
|
+
renderer.line("No legacy index found for this project.");
|
|
83
|
+
renderer.line(`Its index would live at ${home}`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
for (const entry of candidates) {
|
|
87
|
+
if (!entry.model) {
|
|
88
|
+
renderer.error(`Skipping ${entry.databasePath}: it does not record which model built it, ` +
|
|
89
|
+
"so there is no way to tell which index it is. Delete it with `lmgrep projects rm`.");
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const target = locator.databasePathForModel(cwd, ModelIdentity.of(entry.model));
|
|
93
|
+
if (existsSync(target)) {
|
|
94
|
+
renderer.error(`Skipping ${entry.databasePath}: ${target} already exists.`);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
this.move(entry.databasePath, target);
|
|
98
|
+
this.registry.record({
|
|
99
|
+
root: locator.projectRootFor(cwd),
|
|
100
|
+
remote: entry.remote,
|
|
101
|
+
databasePath: target,
|
|
102
|
+
model: entry.model,
|
|
103
|
+
dimensions: entry.dimensions,
|
|
104
|
+
});
|
|
105
|
+
renderer.line(`Adopted ${DiskUsage.format(entry.bytes)} — ${entry.model}\n ${entry.databasePath}\n → ${target}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async remove(database, options) {
|
|
109
|
+
const { renderer } = this.context;
|
|
110
|
+
const path = database ?? this.locator().databasePathFor(this.context.cwd);
|
|
111
|
+
if (!existsSync(path)) {
|
|
112
|
+
renderer.line(`No index at ${path}`);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// This is a recursive delete and the path can come from the command
|
|
116
|
+
// line, so refuse anything that is not recognizably ours — without
|
|
117
|
+
// this, a mistyped argument removes a working tree.
|
|
118
|
+
if (!this.metadata.isDatabaseDirectory(path)) {
|
|
119
|
+
renderer.error(`Refusing to delete ${path}: not an lmgrep database ` +
|
|
120
|
+
"(no lmgrep.json or LanceDB tables).");
|
|
121
|
+
process.exitCode = 1;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (!options.force && !(await this.confirm(`Delete index at ${path}?`))) {
|
|
125
|
+
renderer.line("Cancelled.");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const bytes = DiskUsage.of(path);
|
|
129
|
+
rmSync(path, { recursive: true, force: true });
|
|
130
|
+
this.registry.forget(path);
|
|
131
|
+
renderer.line(`Deleted ${path} (${DiskUsage.format(bytes)})`);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Delete indexes whose project is gone.
|
|
135
|
+
*
|
|
136
|
+
* "Records no project" is excluded unless asked for. It is a recursive
|
|
137
|
+
* delete, and an index with no metadata is not evidence that its project
|
|
138
|
+
* vanished — only that nothing was written down about it. Treating the two
|
|
139
|
+
* as one would have made `gc` destroy far more than it claimed to.
|
|
140
|
+
*/
|
|
141
|
+
async collect(options) {
|
|
142
|
+
const { renderer } = this.context;
|
|
143
|
+
const inventory = this.inventory().collect();
|
|
144
|
+
const dead = inventory.entries.filter((e) => e.state === "orphaned" ||
|
|
145
|
+
(options.unknown && e.state === "unattributable"));
|
|
146
|
+
const skipped = options.unknown
|
|
147
|
+
? 0
|
|
148
|
+
: inventory.entries.filter((e) => e.state === "unattributable").length;
|
|
149
|
+
if (dead.length === 0 && inventory.dangling === 0) {
|
|
150
|
+
renderer.line("Nothing to collect — every index has a project.");
|
|
151
|
+
if (skipped > 0) {
|
|
152
|
+
renderer.line(`${skipped} index(es) record no project. \`--unknown\` includes them.`);
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (dead.length > 0) {
|
|
157
|
+
const bytes = dead.reduce((sum, e) => sum + e.bytes, 0);
|
|
158
|
+
renderer.line(`${dead.length} index(es) whose project is gone — ${DiskUsage.format(bytes)}:\n`);
|
|
159
|
+
for (const entry of dead) {
|
|
160
|
+
renderer.line(` ${DiskUsage.format(entry.bytes).padStart(6)} ${entry.root ?? "(records no project)"}`);
|
|
161
|
+
renderer.line(` ${entry.databasePath}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (skipped > 0) {
|
|
165
|
+
const bytes = inventory.entries
|
|
166
|
+
.filter((e) => e.state === "unattributable")
|
|
167
|
+
.reduce((sum, e) => sum + e.bytes, 0);
|
|
168
|
+
renderer.line(`\nSkipping ${skipped} index(es) that record no project (${DiskUsage.format(bytes)}). ` +
|
|
169
|
+
"Pass `--unknown` to delete those too.");
|
|
170
|
+
}
|
|
171
|
+
if (inventory.dangling > 0) {
|
|
172
|
+
renderer.line(`\n${inventory.dangling} registry pointer(s) to databases that no longer exist.`);
|
|
173
|
+
}
|
|
174
|
+
if (options.dry) {
|
|
175
|
+
renderer.line("\nDry run — nothing deleted.");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (!options.force && !(await this.confirm("\nDelete all of the above?"))) {
|
|
179
|
+
renderer.line("Cancelled.");
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
let reclaimed = 0;
|
|
183
|
+
for (const entry of dead) {
|
|
184
|
+
// An index with no recorded project could be anything, including a
|
|
185
|
+
// directory someone aimed `--in` at. Verify before recursing.
|
|
186
|
+
if (!this.metadata.isDatabaseDirectory(entry.databasePath)) {
|
|
187
|
+
renderer.error(`Skipped ${entry.databasePath}: not an lmgrep database.`);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
rmSync(entry.databasePath, { recursive: true, force: true });
|
|
191
|
+
this.registry.forget(entry.databasePath);
|
|
192
|
+
reclaimed += entry.bytes;
|
|
193
|
+
}
|
|
194
|
+
for (const entry of this.registry.dangling()) {
|
|
195
|
+
this.registry.forget(entry.databasePath);
|
|
196
|
+
}
|
|
197
|
+
renderer.line(`Reclaimed ${DiskUsage.format(reclaimed)}.`);
|
|
198
|
+
}
|
|
199
|
+
/** Whether a legacy entry describes the project at `cwd`. */
|
|
200
|
+
sameProject(entry, cwd) {
|
|
201
|
+
const project = this.locator().resolveProject(cwd);
|
|
202
|
+
if (entry.remote && project.remote)
|
|
203
|
+
return entry.remote === project.remote;
|
|
204
|
+
return entry.root === project.root;
|
|
205
|
+
}
|
|
206
|
+
/** Rename when possible; copy across filesystems, which repos often are. */
|
|
207
|
+
move(from, to) {
|
|
208
|
+
mkdirSync(dirname(to), { recursive: true });
|
|
209
|
+
try {
|
|
210
|
+
renameSync(from, to);
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
cpSync(from, to, { recursive: true });
|
|
214
|
+
rmSync(from, { recursive: true, force: true });
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
inventory() {
|
|
218
|
+
return new IndexInventory(this.registry, this.metadata, this.state, (path) => DiskUsage.of(path));
|
|
219
|
+
}
|
|
220
|
+
locator() {
|
|
221
|
+
const config = new ConfigLoader().load(this.context.cwd);
|
|
222
|
+
return new ProjectLocator(new GitClient(), this.state, ModelIdentity.of(config.model), config.dimensions);
|
|
223
|
+
}
|
|
224
|
+
async confirm(question) {
|
|
225
|
+
const rl = createInterface({
|
|
226
|
+
input: process.stdin,
|
|
227
|
+
output: process.stdout,
|
|
228
|
+
});
|
|
229
|
+
try {
|
|
230
|
+
const answer = await new Promise((resolve) => {
|
|
231
|
+
rl.question(`${question} [y/N] `, resolve);
|
|
232
|
+
});
|
|
233
|
+
return answer.trim().toLowerCase().startsWith("y");
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
rl.close();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=ProjectsCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectsCommand.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/ProjectsCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EACN,cAAc,GAEd,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAGrE;;;;;;;;;GASG;AACH,MAAM,OAAO,eAAe;IAKE;IAJZ,KAAK,GAAG,IAAI,cAAc,EAAE,CAAC;IAC7B,QAAQ,GAAG,IAAI,oBAAoB,EAAE,CAAC;IACtC,QAAQ,GAAG,IAAI,eAAe,C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AC,OAAO,CAAC,GAAG,CAAC,CAAC;QACzD,OAAO,IAAI,cAAc,CACxB,IAAI,SAAS,EAAE,EACf,IAAI,CAAC,KAAK,EACV,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAC9B,MAAM,CAAC,UAAU,CACjB,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,QAAgB;QACrC,MAAM,EAAE,GAAG,eAAe,CAAC;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;SACtB,CAAC,CAAC;QACH,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,MAAM,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;gBACpD,EAAE,CAAC,QAAQ,CAAC,GAAG,QAAQ,SAAS,EAAE,OAAO,CAAC,CAAC;YAC5C,CAAC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACpD,CAAC;gBAAS,CAAC;YACV,EAAE,CAAC,KAAK,EAAE,CAAC;QACZ,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { CommandContext } from "../CommandContext.js";
|
|
3
|
+
/**
|
|
4
|
+
* `lmgrep search` — the primary read path, and what a bare `lmgrep <query>`
|
|
5
|
+
* runs.
|
|
6
|
+
*
|
|
7
|
+
* The options here are the ones a person can answer from what they already
|
|
8
|
+
* know: how many results, where to look, which languages. Three that used to
|
|
9
|
+
* exist are gone because they could only be set by trial and error —
|
|
10
|
+
* `--min-score` needs the score distribution of your embedding model,
|
|
11
|
+
* `--type` needs tree-sitter's per-language node names, and `--not` doubled
|
|
12
|
+
* the cost of a query to express something a better query expresses anyway.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SearchCommand {
|
|
15
|
+
private readonly context;
|
|
16
|
+
constructor(context: CommandContext);
|
|
17
|
+
register(program: Command): void;
|
|
18
|
+
private run;
|
|
19
|
+
}
|