lmgrep 0.1.18 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +253 -62
- package/completions/_lmgrep +49 -40
- package/dist/application/Lmgrep.d.ts +107 -0
- package/dist/application/Lmgrep.js +99 -0
- package/dist/application/Lmgrep.js.map +1 -0
- package/dist/application/LmgrepFactory.d.ts +40 -0
- package/dist/application/LmgrepFactory.js +155 -0
- package/dist/application/LmgrepFactory.js.map +1 -0
- package/dist/application/indexing/BranchBootstrapper.d.ts +21 -0
- package/dist/application/indexing/BranchBootstrapper.js +52 -0
- package/dist/application/indexing/BranchBootstrapper.js.map +1 -0
- package/dist/application/indexing/BranchManifestSweeper.d.ts +17 -0
- package/dist/application/indexing/BranchManifestSweeper.js +35 -0
- package/dist/application/indexing/BranchManifestSweeper.js.map +1 -0
- package/dist/application/indexing/Duration.d.ts +9 -0
- package/dist/application/indexing/Duration.js +25 -0
- package/dist/application/indexing/Duration.js.map +1 -0
- package/dist/application/indexing/EmbeddingAbortError.d.ts +11 -0
- package/dist/application/indexing/EmbeddingAbortError.js +20 -0
- package/dist/application/indexing/EmbeddingAbortError.js.map +1 -0
- package/dist/application/indexing/EmbeddingPipeline.d.ts +59 -0
- package/dist/application/indexing/EmbeddingPipeline.js +140 -0
- package/dist/application/indexing/EmbeddingPipeline.js.map +1 -0
- package/dist/application/indexing/IndexBuilder.d.ts +112 -0
- package/dist/application/indexing/IndexBuilder.js +370 -0
- package/dist/application/indexing/IndexBuilder.js.map +1 -0
- package/dist/application/indexing/IndexingProgress.d.ts +34 -0
- package/dist/application/indexing/IndexingProgress.js +2 -0
- package/dist/application/indexing/IndexingProgress.js.map +1 -0
- package/dist/application/operations/Deadline.d.ts +13 -0
- package/dist/application/operations/Deadline.js +29 -0
- package/dist/application/operations/Deadline.js.map +1 -0
- package/dist/application/operations/HealthMonitor.d.ts +58 -0
- package/dist/application/operations/HealthMonitor.js +128 -0
- package/dist/application/operations/HealthMonitor.js.map +1 -0
- package/dist/application/operations/IndexAlternatives.d.ts +35 -0
- package/dist/application/operations/IndexAlternatives.js +61 -0
- package/dist/application/operations/IndexAlternatives.js.map +1 -0
- package/dist/application/operations/IndexInventory.d.ts +69 -0
- package/dist/application/operations/IndexInventory.js +99 -0
- package/dist/application/operations/IndexInventory.js.map +1 -0
- package/dist/application/operations/StatusService.d.ts +90 -0
- package/dist/application/operations/StatusService.js +171 -0
- package/dist/application/operations/StatusService.js.map +1 -0
- package/dist/application/operations/WatchService.d.ts +67 -0
- package/dist/application/operations/WatchService.js +145 -0
- package/dist/application/operations/WatchService.js.map +1 -0
- package/dist/application/operations/WorkingTreeDiff.d.ts +19 -0
- package/dist/application/operations/WorkingTreeDiff.js +36 -0
- package/dist/application/operations/WorkingTreeDiff.js.map +1 -0
- package/dist/application/research/ResearchAgent.d.ts +68 -0
- package/dist/application/research/ResearchAgent.js +201 -0
- package/dist/application/research/ResearchAgent.js.map +1 -0
- package/dist/application/research/ResearchPrompts.d.ts +16 -0
- package/dist/application/research/ResearchPrompts.js +34 -0
- package/dist/application/research/ResearchPrompts.js.map +1 -0
- package/dist/application/search/SearchCriteria.d.ts +37 -0
- package/dist/application/search/SearchCriteria.js +48 -0
- package/dist/application/search/SearchCriteria.js.map +1 -0
- package/dist/application/search/SearchService.d.ts +36 -0
- package/dist/application/search/SearchService.js +108 -0
- package/dist/application/search/SearchService.js.map +1 -0
- package/dist/application/search/SearchTargetResolver.d.ts +56 -0
- package/dist/application/search/SearchTargetResolver.js +104 -0
- package/dist/application/search/SearchTargetResolver.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +4 -953
- package/dist/cli.js.map +1 -1
- package/dist/domain/config/ConfigSource.d.ts +16 -0
- package/dist/domain/config/ConfigSource.js +2 -0
- package/dist/domain/config/ConfigSource.js.map +1 -0
- package/dist/domain/config/LmgrepConfig.d.ts +53 -0
- package/dist/domain/config/LmgrepConfig.js +2 -0
- package/dist/domain/config/LmgrepConfig.js.map +1 -0
- package/dist/domain/corpus/Chunk.d.ts +49 -0
- package/dist/domain/corpus/Chunk.js +60 -0
- package/dist/domain/corpus/Chunk.js.map +1 -0
- package/dist/domain/corpus/CodeLocation.d.ts +18 -0
- package/dist/domain/corpus/CodeLocation.js +34 -0
- package/dist/domain/corpus/CodeLocation.js.map +1 -0
- package/dist/domain/corpus/ContentHash.d.ts +15 -0
- package/dist/domain/corpus/ContentHash.js +30 -0
- package/dist/domain/corpus/ContentHash.js.map +1 -0
- package/dist/domain/corpus/FileVersion.d.ts +31 -0
- package/dist/domain/corpus/FileVersion.js +47 -0
- package/dist/domain/corpus/FileVersion.js.map +1 -0
- package/dist/domain/corpus/SourceFile.d.ts +26 -0
- package/dist/domain/corpus/SourceFile.js +47 -0
- package/dist/domain/corpus/SourceFile.js.map +1 -0
- package/dist/domain/corpus/Vector.d.ts +37 -0
- package/dist/domain/corpus/Vector.js +96 -0
- package/dist/domain/corpus/Vector.js.map +1 -0
- package/dist/domain/ports/ChatModelPort.d.ts +57 -0
- package/dist/domain/ports/ChatModelPort.js +2 -0
- package/dist/domain/ports/ChatModelPort.js.map +1 -0
- package/dist/domain/ports/ChunkRepositoryPort.d.ts +42 -0
- package/dist/domain/ports/ChunkRepositoryPort.js +2 -0
- package/dist/domain/ports/ChunkRepositoryPort.js.map +1 -0
- package/dist/domain/ports/ChunkerPort.d.ts +5 -0
- package/dist/domain/ports/ChunkerPort.js +2 -0
- package/dist/domain/ports/ChunkerPort.js.map +1 -0
- package/dist/domain/ports/DatabaseSessionPort.d.ts +10 -0
- package/dist/domain/ports/DatabaseSessionPort.js +2 -0
- package/dist/domain/ports/DatabaseSessionPort.js.map +1 -0
- package/dist/domain/ports/EmbedderPort.d.ts +14 -0
- package/dist/domain/ports/EmbedderPort.js +2 -0
- package/dist/domain/ports/EmbedderPort.js.map +1 -0
- package/dist/domain/ports/FileManifestRepositoryPort.d.ts +32 -0
- package/dist/domain/ports/FileManifestRepositoryPort.js +2 -0
- package/dist/domain/ports/FileManifestRepositoryPort.js.map +1 -0
- package/dist/domain/ports/GitPort.d.ts +24 -0
- package/dist/domain/ports/GitPort.js +2 -0
- package/dist/domain/ports/GitPort.js.map +1 -0
- package/dist/domain/ports/IndexMaintenancePort.d.ts +58 -0
- package/dist/domain/ports/IndexMaintenancePort.js +2 -0
- package/dist/domain/ports/IndexMaintenancePort.js.map +1 -0
- package/dist/domain/ports/IndexMetadataPort.d.ts +23 -0
- package/dist/domain/ports/IndexMetadataPort.js +2 -0
- package/dist/domain/ports/IndexMetadataPort.js.map +1 -0
- package/dist/domain/ports/LockPort.d.ts +17 -0
- package/dist/domain/ports/LockPort.js +2 -0
- package/dist/domain/ports/LockPort.js.map +1 -0
- package/dist/domain/ports/LoggerPort.d.ts +5 -0
- package/dist/domain/ports/LoggerPort.js +2 -0
- package/dist/domain/ports/LoggerPort.js.map +1 -0
- package/dist/domain/ports/ProjectIndexesPort.d.ts +20 -0
- package/dist/domain/ports/ProjectIndexesPort.js +2 -0
- package/dist/domain/ports/ProjectIndexesPort.js.map +1 -0
- package/dist/domain/ports/ProjectRegistryPort.d.ts +42 -0
- package/dist/domain/ports/ProjectRegistryPort.js +2 -0
- package/dist/domain/ports/ProjectRegistryPort.js.map +1 -0
- package/dist/domain/ports/StateDirectoryPort.d.ts +29 -0
- package/dist/domain/ports/StateDirectoryPort.js +2 -0
- package/dist/domain/ports/StateDirectoryPort.js.map +1 -0
- package/dist/domain/ports/WorkspacePort.d.ts +38 -0
- package/dist/domain/ports/WorkspacePort.js +2 -0
- package/dist/domain/ports/WorkspacePort.js.map +1 -0
- package/dist/domain/project/Branch.d.ts +20 -0
- package/dist/domain/project/Branch.js +33 -0
- package/dist/domain/project/Branch.js.map +1 -0
- package/dist/domain/project/DatabaseLocation.d.ts +32 -0
- package/dist/domain/project/DatabaseLocation.js +35 -0
- package/dist/domain/project/DatabaseLocation.js.map +1 -0
- package/dist/domain/project/IndexMetadata.d.ts +17 -0
- package/dist/domain/project/IndexMetadata.js +2 -0
- package/dist/domain/project/IndexMetadata.js.map +1 -0
- package/dist/domain/project/ModelIdentity.d.ts +58 -0
- package/dist/domain/project/ModelIdentity.js +94 -0
- package/dist/domain/project/ModelIdentity.js.map +1 -0
- package/dist/domain/project/Project.d.ts +17 -0
- package/dist/domain/project/Project.js +21 -0
- package/dist/domain/project/Project.js.map +1 -0
- package/dist/domain/project/ProjectId.d.ts +28 -0
- package/dist/domain/project/ProjectId.js +58 -0
- package/dist/domain/project/ProjectId.js.map +1 -0
- package/dist/domain/project/ProjectLocator.d.ts +112 -0
- package/dist/domain/project/ProjectLocator.js +178 -0
- package/dist/domain/project/ProjectLocator.js.map +1 -0
- package/dist/domain/research/Citation.d.ts +27 -0
- package/dist/domain/research/Citation.js +43 -0
- package/dist/domain/research/Citation.js.map +1 -0
- package/dist/domain/research/EvidenceLedger.d.ts +47 -0
- package/dist/domain/research/EvidenceLedger.js +111 -0
- package/dist/domain/research/EvidenceLedger.js.map +1 -0
- package/dist/domain/research/ResearchTrace.d.ts +19 -0
- package/dist/domain/research/ResearchTrace.js +22 -0
- package/dist/domain/research/ResearchTrace.js.map +1 -0
- package/dist/domain/retrieval/Hit.d.ts +19 -0
- package/dist/domain/retrieval/Hit.js +28 -0
- package/dist/domain/retrieval/Hit.js.map +1 -0
- package/dist/domain/retrieval/HitList.d.ts +35 -0
- package/dist/domain/retrieval/HitList.js +81 -0
- package/dist/domain/retrieval/HitList.js.map +1 -0
- package/dist/domain/retrieval/MissingIndexError.d.ts +11 -0
- package/dist/domain/retrieval/MissingIndexError.js +15 -0
- package/dist/domain/retrieval/MissingIndexError.js.map +1 -0
- package/dist/index.d.ts +43 -45
- package/dist/index.js +30 -567
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/ai/AiSdkChatModel.d.ts +31 -0
- package/dist/infrastructure/ai/AiSdkChatModel.js +137 -0
- package/dist/infrastructure/ai/AiSdkChatModel.js.map +1 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.d.ts +28 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.js +79 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.js.map +1 -0
- package/dist/infrastructure/ai/DockerModelRunnerProbe.d.ts +16 -0
- package/dist/infrastructure/ai/DockerModelRunnerProbe.js +52 -0
- package/dist/infrastructure/ai/DockerModelRunnerProbe.js.map +1 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.d.ts +21 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.js +40 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.js.map +1 -0
- package/dist/infrastructure/ai/LmStudioProbe.d.ts +18 -0
- package/dist/infrastructure/ai/LmStudioProbe.js +49 -0
- package/dist/infrastructure/ai/LmStudioProbe.js.map +1 -0
- package/dist/infrastructure/ai/LocalModelReloader.d.ts +21 -0
- package/dist/infrastructure/ai/LocalModelReloader.js +61 -0
- package/dist/infrastructure/ai/LocalModelReloader.js.map +1 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.d.ts +36 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.js +63 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.js.map +1 -0
- package/dist/infrastructure/ai/ModelRuntime.d.ts +32 -0
- package/dist/infrastructure/ai/ModelRuntime.js +2 -0
- package/dist/infrastructure/ai/ModelRuntime.js.map +1 -0
- package/dist/infrastructure/ai/OllamaProbe.d.ts +22 -0
- package/dist/infrastructure/ai/OllamaProbe.js +71 -0
- package/dist/infrastructure/ai/OllamaProbe.js.map +1 -0
- package/dist/infrastructure/ai/ProviderFailure.d.ts +16 -0
- package/dist/infrastructure/ai/ProviderFailure.js +35 -0
- package/dist/infrastructure/ai/ProviderFailure.js.map +1 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.d.ts +14 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.js +56 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.js.map +1 -0
- package/dist/infrastructure/ai/ProviderRegistry.d.ts +38 -0
- package/dist/infrastructure/ai/ProviderRegistry.js +63 -0
- package/dist/infrastructure/ai/ProviderRegistry.js.map +1 -0
- package/dist/infrastructure/fs/ConfigLoader.d.ts +59 -0
- package/dist/infrastructure/fs/ConfigLoader.js +194 -0
- package/dist/infrastructure/fs/ConfigLoader.js.map +1 -0
- package/dist/infrastructure/fs/DatabaseLocks.d.ts +52 -0
- package/dist/infrastructure/fs/DatabaseLocks.js +92 -0
- package/dist/infrastructure/fs/DatabaseLocks.js.map +1 -0
- package/dist/infrastructure/fs/DiskUsage.d.ts +6 -0
- package/dist/infrastructure/fs/DiskUsage.js +41 -0
- package/dist/infrastructure/fs/DiskUsage.js.map +1 -0
- package/dist/infrastructure/fs/IndexableFileRules.d.ts +33 -0
- package/dist/infrastructure/fs/IndexableFileRules.js +177 -0
- package/dist/infrastructure/fs/IndexableFileRules.js.map +1 -0
- package/dist/infrastructure/fs/Loggers.d.ts +14 -0
- package/dist/infrastructure/fs/Loggers.js +18 -0
- package/dist/infrastructure/fs/Loggers.js.map +1 -0
- package/dist/infrastructure/fs/PidFileLock.d.ts +40 -0
- package/dist/infrastructure/fs/PidFileLock.js +97 -0
- package/dist/infrastructure/fs/PidFileLock.js.map +1 -0
- package/dist/infrastructure/fs/ProjectIndexes.d.ts +8 -0
- package/dist/infrastructure/fs/ProjectIndexes.js +35 -0
- package/dist/infrastructure/fs/ProjectIndexes.js.map +1 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.d.ts +42 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.js +86 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.js.map +1 -0
- package/dist/infrastructure/fs/ProjectRegistry.d.ts +25 -0
- package/dist/infrastructure/fs/ProjectRegistry.js +83 -0
- package/dist/infrastructure/fs/ProjectRegistry.js.map +1 -0
- package/dist/infrastructure/fs/StateDirectory.d.ts +28 -0
- package/dist/infrastructure/fs/StateDirectory.js +71 -0
- package/dist/infrastructure/fs/StateDirectory.js.map +1 -0
- package/dist/infrastructure/fs/Workspace.d.ts +25 -0
- package/dist/infrastructure/fs/Workspace.js +90 -0
- package/dist/infrastructure/fs/Workspace.js.map +1 -0
- package/dist/infrastructure/git/GitClient.d.ts +34 -0
- package/dist/infrastructure/git/GitClient.js +74 -0
- package/dist/infrastructure/git/GitClient.js.map +1 -0
- package/dist/infrastructure/lancedb/ChunkRepository.d.ts +38 -0
- package/dist/infrastructure/lancedb/ChunkRepository.js +166 -0
- package/dist/infrastructure/lancedb/ChunkRepository.js.map +1 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.d.ts +22 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.js +74 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.js.map +1 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.d.ts +34 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.js +137 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.js.map +1 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.d.ts +53 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.js +227 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.js.map +1 -0
- package/dist/infrastructure/lancedb/LanceTables.d.ts +67 -0
- package/dist/infrastructure/lancedb/LanceTables.js +159 -0
- package/dist/infrastructure/lancedb/LanceTables.js.map +1 -0
- package/dist/{lib/native-tuning.js → infrastructure/lancedb/NativeTuning.js} +1 -1
- package/dist/infrastructure/lancedb/NativeTuning.js.map +1 -0
- package/dist/infrastructure/lancedb/RowReplication.d.ts +27 -0
- package/dist/infrastructure/lancedb/RowReplication.js +82 -0
- package/dist/infrastructure/lancedb/RowReplication.js.map +1 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.d.ts +60 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.js +72 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.js.map +1 -0
- package/dist/infrastructure/p2p/IndexShare.d.ts +45 -0
- package/dist/infrastructure/p2p/IndexShare.js +160 -0
- package/dist/infrastructure/p2p/IndexShare.js.map +1 -0
- package/dist/infrastructure/p2p/PeerSwarm.d.ts +16 -0
- package/dist/infrastructure/p2p/PeerSwarm.js +41 -0
- package/dist/infrastructure/p2p/PeerSwarm.js.map +1 -0
- package/dist/infrastructure/p2p/SecureChannel.d.ts +60 -0
- package/dist/infrastructure/p2p/SecureChannel.js +71 -0
- package/dist/infrastructure/p2p/SecureChannel.js.map +1 -0
- package/dist/infrastructure/p2p/ShareCode.d.ts +25 -0
- package/dist/infrastructure/p2p/ShareCode.js +304 -0
- package/dist/infrastructure/p2p/ShareCode.js.map +1 -0
- package/dist/infrastructure/process/ProcessRegistry.d.ts +50 -0
- package/dist/infrastructure/process/ProcessRegistry.js +109 -0
- package/dist/infrastructure/process/ProcessRegistry.js.map +1 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.d.ts +45 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.js +159 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.js.map +1 -0
- package/dist/infrastructure/treesitter/EmbeddedTreeSitterAssets.d.ts +8 -0
- package/dist/infrastructure/treesitter/EmbeddedTreeSitterAssets.js +12 -0
- package/dist/infrastructure/treesitter/EmbeddedTreeSitterAssets.js.map +1 -0
- package/dist/infrastructure/treesitter/LanguageCatalog.d.ts +30 -0
- package/dist/{lib/chunker/languages.js → infrastructure/treesitter/LanguageCatalog.js} +38 -29
- package/dist/infrastructure/treesitter/LanguageCatalog.js.map +1 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.d.ts +15 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.js +42 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.js.map +1 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.d.ts +42 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.js +165 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.js.map +1 -0
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +14 -72
- package/dist/mcp.js.map +1 -1
- package/dist/presentation/cli/Cli.d.ts +31 -0
- package/dist/presentation/cli/Cli.js +120 -0
- package/dist/presentation/cli/Cli.js.map +1 -0
- package/dist/presentation/cli/CliOptions.d.ts +18 -0
- package/dist/presentation/cli/CliOptions.js +25 -0
- package/dist/presentation/cli/CliOptions.js.map +1 -0
- package/dist/presentation/cli/CommandContext.d.ts +50 -0
- package/dist/presentation/cli/CommandContext.js +88 -0
- package/dist/presentation/cli/CommandContext.js.map +1 -0
- package/dist/presentation/cli/ConfigTemplate.d.ts +31 -0
- package/dist/presentation/cli/ConfigTemplate.js +83 -0
- package/dist/presentation/cli/ConfigTemplate.js.map +1 -0
- package/dist/presentation/cli/Renderer.d.ts +90 -0
- package/dist/presentation/cli/Renderer.js +290 -0
- package/dist/presentation/cli/Renderer.js.map +1 -0
- package/dist/presentation/cli/commands/AskCommand.d.ts +14 -0
- package/dist/presentation/cli/commands/AskCommand.js +48 -0
- package/dist/presentation/cli/commands/AskCommand.js.map +1 -0
- package/dist/presentation/cli/commands/CompletionsCommand.d.ts +18 -0
- package/dist/presentation/cli/commands/CompletionsCommand.js +96 -0
- package/dist/presentation/cli/commands/CompletionsCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ConfigCommands.d.ts +56 -0
- package/dist/presentation/cli/commands/ConfigCommands.js +220 -0
- package/dist/presentation/cli/commands/ConfigCommands.js.map +1 -0
- package/dist/presentation/cli/commands/IndexCommand.d.ts +18 -0
- package/dist/presentation/cli/commands/IndexCommand.js +54 -0
- package/dist/presentation/cli/commands/IndexCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ProjectsCommand.d.ts +48 -0
- package/dist/presentation/cli/commands/ProjectsCommand.js +240 -0
- package/dist/presentation/cli/commands/ProjectsCommand.js.map +1 -0
- package/dist/presentation/cli/commands/SearchCommand.d.ts +19 -0
- package/dist/presentation/cli/commands/SearchCommand.js +55 -0
- package/dist/presentation/cli/commands/SearchCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ServerCommands.d.ts +13 -0
- package/dist/presentation/cli/commands/ServerCommands.js +40 -0
- package/dist/presentation/cli/commands/ServerCommands.js.map +1 -0
- package/dist/presentation/cli/commands/ShareCommands.d.ts +22 -0
- package/dist/presentation/cli/commands/ShareCommands.js +134 -0
- package/dist/presentation/cli/commands/ShareCommands.js.map +1 -0
- package/dist/presentation/cli/commands/StatusCommand.d.ts +15 -0
- package/dist/presentation/cli/commands/StatusCommand.js +53 -0
- package/dist/presentation/cli/commands/StatusCommand.js.map +1 -0
- package/dist/presentation/mcp/HitFormatter.d.ts +17 -0
- package/dist/presentation/mcp/HitFormatter.js +42 -0
- package/dist/presentation/mcp/HitFormatter.js.map +1 -0
- package/dist/presentation/mcp/IndexWatchController.d.ts +17 -0
- package/dist/presentation/mcp/IndexWatchController.js +31 -0
- package/dist/presentation/mcp/IndexWatchController.js.map +1 -0
- package/dist/presentation/mcp/LmgrepCore.d.ts +66 -0
- package/dist/presentation/mcp/LmgrepCore.js +178 -0
- package/dist/presentation/mcp/LmgrepCore.js.map +1 -0
- package/dist/presentation/mcp/McpServer.d.ts +18 -0
- package/dist/presentation/mcp/McpServer.js +63 -0
- package/dist/presentation/mcp/McpServer.js.map +1 -0
- package/dist/presentation/mcp/ToolDescriptions.d.ts +40 -0
- package/dist/presentation/mcp/ToolDescriptions.js +85 -0
- package/dist/presentation/mcp/ToolDescriptions.js.map +1 -0
- package/package.json +93 -89
- package/dist/lib/build.d.ts +0 -21
- package/dist/lib/build.js +0 -374
- package/dist/lib/build.js.map +0 -1
- package/dist/lib/chunker/context.d.ts +0 -21
- package/dist/lib/chunker/context.js +0 -131
- package/dist/lib/chunker/context.js.map +0 -1
- package/dist/lib/chunker/index.d.ts +0 -7
- package/dist/lib/chunker/index.js +0 -209
- package/dist/lib/chunker/index.js.map +0 -1
- package/dist/lib/chunker/languages.d.ts +0 -15
- package/dist/lib/chunker/languages.js.map +0 -1
- package/dist/lib/config.d.ts +0 -12
- package/dist/lib/config.js +0 -83
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/embedder.d.ts +0 -65
- package/dist/lib/embedder.js +0 -236
- package/dist/lib/embedder.js.map +0 -1
- package/dist/lib/facet-session.d.ts +0 -44
- package/dist/lib/facet-session.js +0 -125
- package/dist/lib/facet-session.js.map +0 -1
- package/dist/lib/native-tuning.js.map +0 -1
- package/dist/lib/p2p.d.ts +0 -32
- package/dist/lib/p2p.js +0 -281
- package/dist/lib/p2p.js.map +0 -1
- package/dist/lib/providers.d.ts +0 -1
- package/dist/lib/providers.js +0 -41
- package/dist/lib/providers.js.map +0 -1
- package/dist/lib/repair.d.ts +0 -10
- package/dist/lib/repair.js +0 -57
- package/dist/lib/repair.js.map +0 -1
- package/dist/lib/scanner.d.ts +0 -34
- package/dist/lib/scanner.js +0 -242
- package/dist/lib/scanner.js.map +0 -1
- package/dist/lib/search-tool.d.ts +0 -55
- package/dist/lib/search-tool.js +0 -319
- package/dist/lib/search-tool.js.map +0 -1
- package/dist/lib/serve.d.ts +0 -11
- package/dist/lib/serve.js +0 -144
- package/dist/lib/serve.js.map +0 -1
- package/dist/lib/store.d.ts +0 -252
- package/dist/lib/store.js +0 -1216
- package/dist/lib/store.js.map +0 -1
- package/dist/lib/types.d.ts +0 -194
- package/dist/lib/types.js +0 -13
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/vocab.d.ts +0 -20
- package/dist/lib/vocab.js +0 -275
- package/dist/lib/vocab.js.map +0 -1
- /package/dist/{lib/native-tuning.d.ts → infrastructure/lancedb/NativeTuning.d.ts} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CliOptions } from "../CliOptions.js";
|
|
2
|
+
import { CommandContext as Ctx } 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 class SearchCommand {
|
|
15
|
+
context;
|
|
16
|
+
constructor(context) {
|
|
17
|
+
this.context = context;
|
|
18
|
+
}
|
|
19
|
+
register(program) {
|
|
20
|
+
CliOptions.target(program
|
|
21
|
+
.command("search <query...>")
|
|
22
|
+
.description("Search the codebase using natural language")
|
|
23
|
+
.option("-m, --limit <n>", "Max results", "25")
|
|
24
|
+
.option("--under <path>", "Only search files under this path")
|
|
25
|
+
.option("--language <exts>", "Only search these file extensions (comma-separated, e.g. .ts,.py)")
|
|
26
|
+
.option("--compact", "Print matching file paths only")
|
|
27
|
+
.option("--json", "Print results as JSON")).action((query, options) => this.run(query.join(" "), options));
|
|
28
|
+
}
|
|
29
|
+
async run(query, options) {
|
|
30
|
+
const { across } = Ctx.targets(options);
|
|
31
|
+
await this.context.withLmgrep(options, async (lmgrep) => {
|
|
32
|
+
const hits = await lmgrep.search(query, {
|
|
33
|
+
limit: Ctx.integer(options.limit, 25),
|
|
34
|
+
filePrefix: options.under,
|
|
35
|
+
language: Ctx.list(options.language),
|
|
36
|
+
across: across.length > 0 ? across : undefined,
|
|
37
|
+
});
|
|
38
|
+
const { renderer } = this.context;
|
|
39
|
+
if (options.json) {
|
|
40
|
+
renderer.json(hits.toArray());
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (hits.isEmpty) {
|
|
44
|
+
renderer.line("No results found.");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (options.compact) {
|
|
48
|
+
renderer.hitPaths(hits.toArray());
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
renderer.hits(hits.toArray());
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=SearchCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchCommand.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/SearchCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,cAAc,IAAI,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAU7D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,aAAa;IACI;IAA7B,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,QAAQ,CAAC,OAAgB;QACxB,UAAU,CAAC,MAAM,CAChB,OAAO;aACL,OAAO,CAAC,mBAAmB,CAAC;aAC5B,WAAW,CAAC,4CAA4C,CAAC;aACzD,MAAM,CAAC,iBAAiB,EAAE,aAAa,EAAE,IAAI,CAAC;aAC9C,MAAM,CAAC,gBAAgB,EAAE,mCAAmC,CAAC;aAC7D,MAAM,CACN,mBAAmB,EACnB,mEAAmE,CACnE;aACA,MAAM,CAAC,WAAW,EAAE,gCAAgC,CAAC;aACrD,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAC3C,CAAC,MAAM,CAAC,CAAC,KAAe,EAAE,OAAsB,EAAE,EAAE,CACpD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAClC,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,GAAG,CAAC,KAAa,EAAE,OAAsB;QACtD,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACvD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;gBACvC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;gBACrC,UAAU,EAAE,OAAO,CAAC,KAAK;gBACzB,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;gBACpC,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aAC9C,CAAC,CAAC;YAEH,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAClC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBAClB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC9B,OAAO;YACR,CAAC;YACD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;gBACnC,OAAO;YACR,CAAC;YACD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrB,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;gBAClC,OAAO;YACR,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { CommandContext } from "../CommandContext.js";
|
|
3
|
+
/**
|
|
4
|
+
* `serve` and `mcp` — the two long-running modes.
|
|
5
|
+
*
|
|
6
|
+
* Both keep the process alive deliberately: `serve` watches for changes, and
|
|
7
|
+
* `mcp` speaks the protocol over stdio until its client disconnects.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ServerCommands {
|
|
10
|
+
private readonly context;
|
|
11
|
+
constructor(context: CommandContext);
|
|
12
|
+
register(program: Command): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CliOptions } from "../CliOptions.js";
|
|
2
|
+
/**
|
|
3
|
+
* `serve` and `mcp` — the two long-running modes.
|
|
4
|
+
*
|
|
5
|
+
* Both keep the process alive deliberately: `serve` watches for changes, and
|
|
6
|
+
* `mcp` speaks the protocol over stdio until its client disconnects.
|
|
7
|
+
*/
|
|
8
|
+
export class ServerCommands {
|
|
9
|
+
context;
|
|
10
|
+
constructor(context) {
|
|
11
|
+
this.context = context;
|
|
12
|
+
}
|
|
13
|
+
register(program) {
|
|
14
|
+
CliOptions.target(program
|
|
15
|
+
.command("serve")
|
|
16
|
+
.description("Watch this project and re-index as files change")).action(async (options) => {
|
|
17
|
+
const lmgrep = await this.context.open(options);
|
|
18
|
+
const stop = lmgrep.watch();
|
|
19
|
+
// Deliberately not closed: the watcher owns this process until
|
|
20
|
+
// it is signalled.
|
|
21
|
+
const shutdown = () => {
|
|
22
|
+
stop();
|
|
23
|
+
void lmgrep.close().finally(() => process.exit(0));
|
|
24
|
+
};
|
|
25
|
+
process.on("SIGINT", shutdown);
|
|
26
|
+
process.on("SIGTERM", shutdown);
|
|
27
|
+
});
|
|
28
|
+
CliOptions.target(program
|
|
29
|
+
.command("mcp")
|
|
30
|
+
.description("Start the MCP server (stdio transport)")).action(async (options) => {
|
|
31
|
+
// The entry point reads its target from the environment, so it can
|
|
32
|
+
// be launched either as `lmgrep mcp` or as `lmgrep-mcp`.
|
|
33
|
+
const target = options.in?.[0];
|
|
34
|
+
if (target)
|
|
35
|
+
process.env.LMGREP_DATABASE = target;
|
|
36
|
+
await import("../../../mcp.js");
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=ServerCommands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServerCommands.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/ServerCommands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C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0 +1,22 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { CommandContext } from "../CommandContext.js";
|
|
3
|
+
/**
|
|
4
|
+
* `export` and `import` — moving an index between machines or databases.
|
|
5
|
+
*
|
|
6
|
+
* Both exist to avoid re-embedding, which is the expensive part of indexing.
|
|
7
|
+
* `import` accepts either a peer share code or a local database path, since
|
|
8
|
+
* "get this index from somewhere else" is one intent to the user.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ShareCommands {
|
|
11
|
+
private readonly context;
|
|
12
|
+
constructor(context: CommandContext);
|
|
13
|
+
register(program: Command): void;
|
|
14
|
+
private registerExport;
|
|
15
|
+
private runExport;
|
|
16
|
+
private registerImport;
|
|
17
|
+
private runImport;
|
|
18
|
+
private importFromPeer;
|
|
19
|
+
private importFromDatabase;
|
|
20
|
+
/** The pieces every share operation needs, resolved from the cwd. */
|
|
21
|
+
private resolve;
|
|
22
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { ModelIdentity } from "../../../domain/project/ModelIdentity.js";
|
|
4
|
+
import { ProjectLocator } from "../../../domain/project/ProjectLocator.js";
|
|
5
|
+
import { ConfigLoader } from "../../../infrastructure/fs/ConfigLoader.js";
|
|
6
|
+
import { ProjectMetadataStore } from "../../../infrastructure/fs/ProjectMetadataStore.js";
|
|
7
|
+
import { StateDirectory } from "../../../infrastructure/fs/StateDirectory.js";
|
|
8
|
+
import { GitClient } from "../../../infrastructure/git/GitClient.js";
|
|
9
|
+
import { DatabaseImporter } from "../../../infrastructure/lancedb/DatabaseImporter.js";
|
|
10
|
+
import { LanceTables } from "../../../infrastructure/lancedb/LanceTables.js";
|
|
11
|
+
import { RowReplication } from "../../../infrastructure/lancedb/RowReplication.js";
|
|
12
|
+
import { IndexShare } from "../../../infrastructure/p2p/IndexShare.js";
|
|
13
|
+
import { ShareCode } from "../../../infrastructure/p2p/ShareCode.js";
|
|
14
|
+
/**
|
|
15
|
+
* `export` and `import` — moving an index between machines or databases.
|
|
16
|
+
*
|
|
17
|
+
* Both exist to avoid re-embedding, which is the expensive part of indexing.
|
|
18
|
+
* `import` accepts either a peer share code or a local database path, since
|
|
19
|
+
* "get this index from somewhere else" is one intent to the user.
|
|
20
|
+
*/
|
|
21
|
+
export class ShareCommands {
|
|
22
|
+
context;
|
|
23
|
+
constructor(context) {
|
|
24
|
+
this.context = context;
|
|
25
|
+
}
|
|
26
|
+
register(program) {
|
|
27
|
+
this.registerExport(program);
|
|
28
|
+
this.registerImport(program);
|
|
29
|
+
}
|
|
30
|
+
registerExport(program) {
|
|
31
|
+
program
|
|
32
|
+
.command("share")
|
|
33
|
+
.description("Offer this project's index to a peer over P2P")
|
|
34
|
+
.action(() => this.runExport());
|
|
35
|
+
}
|
|
36
|
+
async runExport() {
|
|
37
|
+
const { renderer } = this.context;
|
|
38
|
+
const { branch, location, metadata } = this.resolve();
|
|
39
|
+
const tables = new LanceTables(location, branch);
|
|
40
|
+
const share = new IndexShare(new RowReplication(tables, branch));
|
|
41
|
+
const { code, done } = await share.send(metadata, {
|
|
42
|
+
onProgress: (sent, total) => process.stderr.write(`\rSending: ${sent}/${total} chunks`),
|
|
43
|
+
});
|
|
44
|
+
renderer.line(`Share code: ${code}`);
|
|
45
|
+
renderer.line("Waiting for peer... (Ctrl+C to cancel)\n");
|
|
46
|
+
await done;
|
|
47
|
+
process.stderr.write("\n");
|
|
48
|
+
renderer.line("Transfer complete.");
|
|
49
|
+
tables.close();
|
|
50
|
+
}
|
|
51
|
+
registerImport(program) {
|
|
52
|
+
program
|
|
53
|
+
.command("import <source>")
|
|
54
|
+
.description("Import chunks from a peer (share code) or another lmgrep database (path)")
|
|
55
|
+
.option("--reset", "Reset the current index before importing")
|
|
56
|
+
.action((source, options) => this.runImport(source, options));
|
|
57
|
+
}
|
|
58
|
+
async runImport(source, options) {
|
|
59
|
+
if (ShareCode.looksLikeCode(source)) {
|
|
60
|
+
await this.importFromPeer(source, options);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
await this.importFromDatabase(source, options);
|
|
64
|
+
}
|
|
65
|
+
async importFromPeer(source, options) {
|
|
66
|
+
const { renderer } = this.context;
|
|
67
|
+
const code = ShareCode.parse(source);
|
|
68
|
+
if (!code)
|
|
69
|
+
throw new Error(`Not a valid share code: ${source}`);
|
|
70
|
+
renderer.line("Connecting to peer...");
|
|
71
|
+
const lmgrep = await this.context.open({});
|
|
72
|
+
if (options.reset)
|
|
73
|
+
await lmgrep.maintenance.reset();
|
|
74
|
+
const { branch, location, metadata } = this.resolve();
|
|
75
|
+
await lmgrep.close();
|
|
76
|
+
const tables = new LanceTables(location, branch);
|
|
77
|
+
const share = new IndexShare(new RowReplication(tables, branch));
|
|
78
|
+
const result = await share.receive(code, metadata, {
|
|
79
|
+
onProgress: (received, total) => process.stderr.write(`\rReceiving: ${received}/${total} chunks`),
|
|
80
|
+
onMeta: (meta) => renderer.line(`Peer index: ${meta.chunkCount} chunks` +
|
|
81
|
+
(meta.model ? `, model: ${meta.model}` : "") +
|
|
82
|
+
(meta.dimensions ? `, ${meta.dimensions} dims` : "")),
|
|
83
|
+
onWarning: (message) => renderer.error(message),
|
|
84
|
+
});
|
|
85
|
+
process.stderr.write("\n");
|
|
86
|
+
renderer.line(`Imported ${result.chunks} chunks and ${result.files} file hashes from peer.`);
|
|
87
|
+
tables.close();
|
|
88
|
+
}
|
|
89
|
+
async importFromDatabase(source, options) {
|
|
90
|
+
const { renderer } = this.context;
|
|
91
|
+
const cwd = this.context.cwd;
|
|
92
|
+
const { branch, location, store } = this.resolve();
|
|
93
|
+
const sourcePath = resolve(cwd, source);
|
|
94
|
+
if (!existsSync(sourcePath)) {
|
|
95
|
+
throw new Error(`Database not found: ${sourcePath}`);
|
|
96
|
+
}
|
|
97
|
+
if (resolve(sourcePath) === resolve(location)) {
|
|
98
|
+
throw new Error("Source and destination are the same database.");
|
|
99
|
+
}
|
|
100
|
+
const lmgrep = await this.context.open({});
|
|
101
|
+
if (options.reset)
|
|
102
|
+
await lmgrep.maintenance.reset();
|
|
103
|
+
await lmgrep.close();
|
|
104
|
+
const tables = new LanceTables(location, branch);
|
|
105
|
+
const { chunks, files } = await new DatabaseImporter(tables, branch).importFrom(sourcePath);
|
|
106
|
+
tables.close();
|
|
107
|
+
renderer.line(`Imported ${chunks} chunks and ${files} file hashes from ${sourcePath}`);
|
|
108
|
+
// The source's model is what these vectors mean; without a matching
|
|
109
|
+
// local model the import is unusable, so say so explicitly.
|
|
110
|
+
const sourceMeta = store.read(sourcePath);
|
|
111
|
+
if (sourceMeta?.model) {
|
|
112
|
+
const family = ModelIdentity.of(sourceMeta.model).family;
|
|
113
|
+
renderer.line(`\nThis index was built with "${sourceMeta.model}" (${family}` +
|
|
114
|
+
`${sourceMeta.dimensions ? `, ${sourceMeta.dimensions} dims` : ""}).`);
|
|
115
|
+
renderer.line("Set that model in your machine config (`lmgrep config`) to search these vectors.");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** The pieces every share operation needs, resolved from the cwd. */
|
|
119
|
+
resolve() {
|
|
120
|
+
const state = new StateDirectory();
|
|
121
|
+
const config = new ConfigLoader().load(this.context.cwd);
|
|
122
|
+
const locator = new ProjectLocator(new GitClient(), state, ModelIdentity.of(config.model), config.dimensions);
|
|
123
|
+
const store = new ProjectMetadataStore();
|
|
124
|
+
const database = locator.resolveDatabase(this.context.cwd);
|
|
125
|
+
return {
|
|
126
|
+
locator,
|
|
127
|
+
branch: database.branch,
|
|
128
|
+
location: database.path,
|
|
129
|
+
metadata: store.read(database.path),
|
|
130
|
+
store,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=ShareCommands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShareCommands.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/ShareCommands.ts"],"names":[],"mappings":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AM,CAAC,UAAU,CACjB,CAAC;QACF,MAAM,KAAK,GAAG,IAAI,oBAAoB,EAAE,CAAC;QACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3D,OAAO;YACN,OAAO;YACP,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,QAAQ,EAAE,QAAQ,CAAC,IAAI;YACvB,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACnC,KAAK;SACL,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { CommandContext } from "../CommandContext.js";
|
|
3
|
+
/**
|
|
4
|
+
* `lmgrep status` — is search working, and if not, what to do.
|
|
5
|
+
*
|
|
6
|
+
* It leads with that one answer. The statistics behind it used to *be* the
|
|
7
|
+
* output, which left every reader to work out the verdict themselves from
|
|
8
|
+
* fifteen lines of counts and latencies.
|
|
9
|
+
*/
|
|
10
|
+
export declare class StatusCommand {
|
|
11
|
+
private readonly context;
|
|
12
|
+
constructor(context: CommandContext);
|
|
13
|
+
register(program: Command): void;
|
|
14
|
+
private run;
|
|
15
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { WorkingTreeDiff } from "../../../application/operations/WorkingTreeDiff.js";
|
|
2
|
+
import { StateDirectory } from "../../../infrastructure/fs/StateDirectory.js";
|
|
3
|
+
import { Workspace } from "../../../infrastructure/fs/Workspace.js";
|
|
4
|
+
import { ProcessRegistry } from "../../../infrastructure/process/ProcessRegistry.js";
|
|
5
|
+
import { CliOptions } from "../CliOptions.js";
|
|
6
|
+
/**
|
|
7
|
+
* `lmgrep status` — is search working, and if not, what to do.
|
|
8
|
+
*
|
|
9
|
+
* It leads with that one answer. The statistics behind it used to *be* the
|
|
10
|
+
* output, which left every reader to work out the verdict themselves from
|
|
11
|
+
* fifteen lines of counts and latencies.
|
|
12
|
+
*/
|
|
13
|
+
export class StatusCommand {
|
|
14
|
+
context;
|
|
15
|
+
constructor(context) {
|
|
16
|
+
this.context = context;
|
|
17
|
+
}
|
|
18
|
+
register(program) {
|
|
19
|
+
CliOptions.target(program
|
|
20
|
+
.command("status")
|
|
21
|
+
.description("Report whether search works, and why not")
|
|
22
|
+
.option("-v, --verbose", "Also show index statistics and probes")
|
|
23
|
+
.option("-c, --changes", "Scan for files changed since the last index")
|
|
24
|
+
.option("--json", "Print status as JSON")).action((options) => this.run(options));
|
|
25
|
+
}
|
|
26
|
+
async run(options) {
|
|
27
|
+
const processes = new ProcessRegistry(new StateDirectory()).discoverRunning();
|
|
28
|
+
await this.context.withLmgrep(options, async (lmgrep) => {
|
|
29
|
+
const info = await lmgrep.status();
|
|
30
|
+
const { renderer } = this.context;
|
|
31
|
+
const changes = options.changes
|
|
32
|
+
? new WorkingTreeDiff(new Workspace()).compute(info.projectRoot, await lmgrep.currentManifest())
|
|
33
|
+
: undefined;
|
|
34
|
+
if (options.json) {
|
|
35
|
+
renderer.json({ ...info, processes, ...(changes ? { changes } : {}) });
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
renderer.statusVerdict(info);
|
|
39
|
+
renderer.statusHeader(info);
|
|
40
|
+
renderer.statusConfig(info);
|
|
41
|
+
if (options.verbose) {
|
|
42
|
+
renderer.statusStats(info);
|
|
43
|
+
renderer.statusChecks(info);
|
|
44
|
+
renderer.runningProcesses(processes);
|
|
45
|
+
}
|
|
46
|
+
if (changes) {
|
|
47
|
+
renderer.line("\nScanning for changes...");
|
|
48
|
+
renderer.changes(changes);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=StatusCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusCommand.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/StatusCommand.ts"],"names":[],"mappings":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MAAM,MAAM,CAAC,eAAe,EAAE,CAC9B;gBACF,CAAC,CAAC,SAAS,CAAC;YAEb,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBAClB,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACvE,OAAO;YACR,CAAC;YAED,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAC7B,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAC5B,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAE5B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrB,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC3B,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBAC5B,QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;YACtC,CAAC;YAED,IAAI,OAAO,EAAE,CAAC;gBACb,QAAQ,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;gBAC3C,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ResearchResult } from "../../application/research/ResearchAgent.js";
|
|
2
|
+
import type { Hit } from "../../domain/retrieval/Hit.js";
|
|
3
|
+
/**
|
|
4
|
+
* Renders results as the plain text an MCP client receives.
|
|
5
|
+
*
|
|
6
|
+
* Format is chosen for an agent reader, not a human one: location and context
|
|
7
|
+
* come first so a hit can be acted on without a follow-up file read, which is
|
|
8
|
+
* the whole point of returning the source inline.
|
|
9
|
+
*/
|
|
10
|
+
export declare class HitFormatter {
|
|
11
|
+
static hits(hits: readonly Hit[]): string;
|
|
12
|
+
static answer(result: ResearchResult): string;
|
|
13
|
+
static projects(projects: ReadonlyArray<{
|
|
14
|
+
root: string;
|
|
15
|
+
remote?: string;
|
|
16
|
+
}>): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders results as the plain text an MCP client receives.
|
|
3
|
+
*
|
|
4
|
+
* Format is chosen for an agent reader, not a human one: location and context
|
|
5
|
+
* come first so a hit can be acted on without a follow-up file read, which is
|
|
6
|
+
* the whole point of returning the source inline.
|
|
7
|
+
*/
|
|
8
|
+
export class HitFormatter {
|
|
9
|
+
static hits(hits) {
|
|
10
|
+
return hits
|
|
11
|
+
.map((hit) => {
|
|
12
|
+
const header = `${hit.location} [${hit.type}] ${hit.name} ` +
|
|
13
|
+
`(score: ${hit.score.toFixed(3)})`;
|
|
14
|
+
const parts = [header];
|
|
15
|
+
if (hit.context)
|
|
16
|
+
parts.push(hit.context);
|
|
17
|
+
parts.push(hit.content);
|
|
18
|
+
return parts.join("\n");
|
|
19
|
+
})
|
|
20
|
+
.join("\n\n---\n\n");
|
|
21
|
+
}
|
|
22
|
+
static answer(result) {
|
|
23
|
+
const parts = [result.answer];
|
|
24
|
+
if (result.sources.length > 0) {
|
|
25
|
+
parts.push(`\nSources:\n${result.sources
|
|
26
|
+
.map((s) => `[${s.n}] ${s.path}:${s.startLine}-${s.endLine}`)
|
|
27
|
+
.join("\n")}`);
|
|
28
|
+
}
|
|
29
|
+
const queries = result.trace.flatMap((t) => t.kind === "search" ? [`"${t.query}"`] : []);
|
|
30
|
+
const meta = `${result.steps} steps, ${(result.elapsedMs / 1000).toFixed(0)}s` +
|
|
31
|
+
`${result.degraded ? ", degraded" : ""}`;
|
|
32
|
+
parts.push(queries.length > 0
|
|
33
|
+
? `\n(searched ${queries.join(", ")} · ${meta})`
|
|
34
|
+
: `\n(${meta})`);
|
|
35
|
+
return parts.join("\n");
|
|
36
|
+
}
|
|
37
|
+
static projects(projects) {
|
|
38
|
+
const lines = projects.map((p) => [p.root, ...(p.remote ? [`(${p.remote})`] : [])].join(" "));
|
|
39
|
+
return `Indexed projects:\n${lines.map((l) => `- ${l}`).join("\n")}`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=HitFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HitFormatter.js","sourceRoot":"","sources":["../../../src/presentation/mcp/HitFormatter.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IACxB,MAAM,CAAC,IAAI,CAAC,IAAoB;QAC/B,OAAO,IAAI;aACT,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,MAAM,MAAM,GACX,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,GAAG;gBAC5C,WAAW,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;YACpC,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC;YACvB,IAAI,GAAG,CAAC,OAAO;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACzC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACxB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC;aACD,IAAI,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,MAAsB;QACnC,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAE9B,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,KAAK,CAAC,IAAI,CACT,eAAe,MAAM,CAAC,OAAO;iBAC3B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,C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EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACtE,CAAC;CACD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Lmgrep } from "../../application/Lmgrep.js";
|
|
2
|
+
/**
|
|
3
|
+
* Owns the file watcher's lifecycle for a long-running server.
|
|
4
|
+
*
|
|
5
|
+
* Starting is idempotent and conditional: only one process can hold a
|
|
6
|
+
* database's maintainer lock, so a second server on the same project simply
|
|
7
|
+
* never starts watching rather than failing.
|
|
8
|
+
*/
|
|
9
|
+
export declare class IndexWatchController {
|
|
10
|
+
private readonly lmgrep;
|
|
11
|
+
private readonly isIndexed;
|
|
12
|
+
private stop;
|
|
13
|
+
private disposed;
|
|
14
|
+
constructor(lmgrep: Lmgrep, isIndexed: () => boolean);
|
|
15
|
+
ensureStarted(): void;
|
|
16
|
+
release(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owns the file watcher's lifecycle for a long-running server.
|
|
3
|
+
*
|
|
4
|
+
* Starting is idempotent and conditional: only one process can hold a
|
|
5
|
+
* database's maintainer lock, so a second server on the same project simply
|
|
6
|
+
* never starts watching rather than failing.
|
|
7
|
+
*/
|
|
8
|
+
export class IndexWatchController {
|
|
9
|
+
lmgrep;
|
|
10
|
+
isIndexed;
|
|
11
|
+
stop;
|
|
12
|
+
disposed = false;
|
|
13
|
+
constructor(lmgrep, isIndexed) {
|
|
14
|
+
this.lmgrep = lmgrep;
|
|
15
|
+
this.isIndexed = isIndexed;
|
|
16
|
+
}
|
|
17
|
+
ensureStarted() {
|
|
18
|
+
if (this.stop || this.disposed)
|
|
19
|
+
return;
|
|
20
|
+
// Nothing to watch until the project has an index.
|
|
21
|
+
if (!this.isIndexed())
|
|
22
|
+
return;
|
|
23
|
+
this.stop = this.lmgrep.watch();
|
|
24
|
+
}
|
|
25
|
+
release() {
|
|
26
|
+
this.disposed = true;
|
|
27
|
+
this.stop?.();
|
|
28
|
+
this.stop = undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=IndexWatchController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexWatchController.js","sourceRoot":"","sources":["../../../src/presentation/mcp/IndexWatchController.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IAKd;IACA;IALV,IAAI,CAA2B;IAC/B,QAAQ,GAAG,KAAK,CAAC;IAEzB,YACkB,MAAc,EACd,SAAwB;QADxB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAe;IACvC,CAAC;IAEJ,aAAa;QACZ,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QACvC,mDAAmD;QACnD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YAAE,OAAO;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,OAAO;QACN,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACvB,CAAC;CACD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type HealthState } from "../../application/operations/HealthMonitor.js";
|
|
2
|
+
import { ToolDescriptions } from "./ToolDescriptions.js";
|
|
3
|
+
export type { HealthState } from "../../application/operations/HealthMonitor.js";
|
|
4
|
+
export interface SearchArgs {
|
|
5
|
+
query: string;
|
|
6
|
+
limit?: number;
|
|
7
|
+
filePrefix?: string;
|
|
8
|
+
type?: string[];
|
|
9
|
+
language?: string[];
|
|
10
|
+
project?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ToolResult {
|
|
13
|
+
text: string;
|
|
14
|
+
isError?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** An indexed project other than the current one. */
|
|
17
|
+
export interface OtherProject {
|
|
18
|
+
root: string;
|
|
19
|
+
remote?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The tool surface shared by the MCP server and the Pi extension.
|
|
23
|
+
*
|
|
24
|
+
* It owns the health story: an agent must be told, in the tool description
|
|
25
|
+
* itself, when search cannot work and what to do instead — a tool that silently
|
|
26
|
+
* returns nothing teaches the agent to stop using it.
|
|
27
|
+
*/
|
|
28
|
+
export declare class LmgrepCore {
|
|
29
|
+
private readonly lmgrep;
|
|
30
|
+
private readonly health;
|
|
31
|
+
private readonly watching;
|
|
32
|
+
private readonly registry;
|
|
33
|
+
readonly askAvailable: boolean;
|
|
34
|
+
private constructor();
|
|
35
|
+
static open(options: {
|
|
36
|
+
cwd: string;
|
|
37
|
+
database?: string;
|
|
38
|
+
}): Promise<LmgrepCore>;
|
|
39
|
+
get cwd(): string;
|
|
40
|
+
get searchParams(): typeof ToolDescriptions.SEARCH_PARAMS;
|
|
41
|
+
get listProjectsDescription(): string;
|
|
42
|
+
get askParam(): {
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
get askDescription(): string;
|
|
46
|
+
currentHealth(): HealthState;
|
|
47
|
+
onHealthChange(listener: (state: HealthState) => void): () => void;
|
|
48
|
+
start(): void;
|
|
49
|
+
buildSearchDescription(): string;
|
|
50
|
+
executeSearch(args: SearchArgs): Promise<ToolResult>;
|
|
51
|
+
executeAsk(args: {
|
|
52
|
+
question: string;
|
|
53
|
+
}): Promise<ToolResult>;
|
|
54
|
+
executeListProjects(): Promise<ToolResult>;
|
|
55
|
+
dispose(): Promise<void>;
|
|
56
|
+
/** Shared failure handling: report, and arm recovery polling. */
|
|
57
|
+
private guarded;
|
|
58
|
+
/**
|
|
59
|
+
* Projects an agent can actually reach with the `project` parameter.
|
|
60
|
+
*
|
|
61
|
+
* Standalone indexes are excluded: they are addressed by name, and their
|
|
62
|
+
* recorded root is merely where they were built from, so offering one as a
|
|
63
|
+
* project path would resolve to a different database.
|
|
64
|
+
*/
|
|
65
|
+
private otherProjects;
|
|
66
|
+
}
|