lmgrep 0.1.17 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +226 -63
- package/completions/_lmgrep +49 -40
- package/dist/application/Lmgrep.d.ts +107 -0
- package/dist/application/Lmgrep.js +99 -0
- package/dist/application/Lmgrep.js.map +1 -0
- package/dist/application/LmgrepFactory.d.ts +40 -0
- package/dist/application/LmgrepFactory.js +155 -0
- package/dist/application/LmgrepFactory.js.map +1 -0
- package/dist/application/indexing/BranchBootstrapper.d.ts +21 -0
- package/dist/application/indexing/BranchBootstrapper.js +52 -0
- package/dist/application/indexing/BranchBootstrapper.js.map +1 -0
- package/dist/application/indexing/BranchManifestSweeper.d.ts +17 -0
- package/dist/application/indexing/BranchManifestSweeper.js +35 -0
- package/dist/application/indexing/BranchManifestSweeper.js.map +1 -0
- package/dist/application/indexing/Duration.d.ts +9 -0
- package/dist/application/indexing/Duration.js +25 -0
- package/dist/application/indexing/Duration.js.map +1 -0
- package/dist/application/indexing/EmbeddingAbortError.d.ts +11 -0
- package/dist/application/indexing/EmbeddingAbortError.js +20 -0
- package/dist/application/indexing/EmbeddingAbortError.js.map +1 -0
- package/dist/application/indexing/EmbeddingPipeline.d.ts +59 -0
- package/dist/application/indexing/EmbeddingPipeline.js +140 -0
- package/dist/application/indexing/EmbeddingPipeline.js.map +1 -0
- package/dist/application/indexing/IndexBuilder.d.ts +112 -0
- package/dist/application/indexing/IndexBuilder.js +370 -0
- package/dist/application/indexing/IndexBuilder.js.map +1 -0
- package/dist/application/indexing/IndexingProgress.d.ts +34 -0
- package/dist/application/indexing/IndexingProgress.js +2 -0
- package/dist/application/indexing/IndexingProgress.js.map +1 -0
- package/dist/application/operations/Deadline.d.ts +13 -0
- package/dist/application/operations/Deadline.js +29 -0
- package/dist/application/operations/Deadline.js.map +1 -0
- package/dist/application/operations/HealthMonitor.d.ts +58 -0
- package/dist/application/operations/HealthMonitor.js +128 -0
- package/dist/application/operations/HealthMonitor.js.map +1 -0
- package/dist/application/operations/IndexAlternatives.d.ts +35 -0
- package/dist/application/operations/IndexAlternatives.js +61 -0
- package/dist/application/operations/IndexAlternatives.js.map +1 -0
- package/dist/application/operations/IndexInventory.d.ts +69 -0
- package/dist/application/operations/IndexInventory.js +99 -0
- package/dist/application/operations/IndexInventory.js.map +1 -0
- package/dist/application/operations/StatusService.d.ts +90 -0
- package/dist/application/operations/StatusService.js +171 -0
- package/dist/application/operations/StatusService.js.map +1 -0
- package/dist/application/operations/WatchService.d.ts +67 -0
- package/dist/application/operations/WatchService.js +145 -0
- package/dist/application/operations/WatchService.js.map +1 -0
- package/dist/application/operations/WorkingTreeDiff.d.ts +19 -0
- package/dist/application/operations/WorkingTreeDiff.js +36 -0
- package/dist/application/operations/WorkingTreeDiff.js.map +1 -0
- package/dist/application/research/ResearchAgent.d.ts +68 -0
- package/dist/application/research/ResearchAgent.js +201 -0
- package/dist/application/research/ResearchAgent.js.map +1 -0
- package/dist/application/research/ResearchPrompts.d.ts +16 -0
- package/dist/application/research/ResearchPrompts.js +34 -0
- package/dist/application/research/ResearchPrompts.js.map +1 -0
- package/dist/application/search/SearchCriteria.d.ts +37 -0
- package/dist/application/search/SearchCriteria.js +48 -0
- package/dist/application/search/SearchCriteria.js.map +1 -0
- package/dist/application/search/SearchService.d.ts +36 -0
- package/dist/application/search/SearchService.js +108 -0
- package/dist/application/search/SearchService.js.map +1 -0
- package/dist/application/search/SearchTargetResolver.d.ts +56 -0
- package/dist/application/search/SearchTargetResolver.js +104 -0
- package/dist/application/search/SearchTargetResolver.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +5 -754
- package/dist/cli.js.map +1 -1
- package/dist/domain/config/ConfigSource.d.ts +16 -0
- package/dist/domain/config/ConfigSource.js +2 -0
- package/dist/domain/config/ConfigSource.js.map +1 -0
- package/dist/domain/config/LmgrepConfig.d.ts +53 -0
- package/dist/domain/config/LmgrepConfig.js +2 -0
- package/dist/domain/config/LmgrepConfig.js.map +1 -0
- package/dist/domain/corpus/Chunk.d.ts +49 -0
- package/dist/domain/corpus/Chunk.js +60 -0
- package/dist/domain/corpus/Chunk.js.map +1 -0
- package/dist/domain/corpus/CodeLocation.d.ts +18 -0
- package/dist/domain/corpus/CodeLocation.js +34 -0
- package/dist/domain/corpus/CodeLocation.js.map +1 -0
- package/dist/domain/corpus/ContentHash.d.ts +15 -0
- package/dist/domain/corpus/ContentHash.js +30 -0
- package/dist/domain/corpus/ContentHash.js.map +1 -0
- package/dist/domain/corpus/FileVersion.d.ts +31 -0
- package/dist/domain/corpus/FileVersion.js +47 -0
- package/dist/domain/corpus/FileVersion.js.map +1 -0
- package/dist/domain/corpus/SourceFile.d.ts +26 -0
- package/dist/domain/corpus/SourceFile.js +47 -0
- package/dist/domain/corpus/SourceFile.js.map +1 -0
- package/dist/domain/corpus/Vector.d.ts +37 -0
- package/dist/domain/corpus/Vector.js +96 -0
- package/dist/domain/corpus/Vector.js.map +1 -0
- package/dist/domain/ports/ChatModelPort.d.ts +57 -0
- package/dist/domain/ports/ChatModelPort.js +2 -0
- package/dist/domain/ports/ChatModelPort.js.map +1 -0
- package/dist/domain/ports/ChunkRepositoryPort.d.ts +42 -0
- package/dist/domain/ports/ChunkRepositoryPort.js +2 -0
- package/dist/domain/ports/ChunkRepositoryPort.js.map +1 -0
- package/dist/domain/ports/ChunkerPort.d.ts +5 -0
- package/dist/domain/ports/ChunkerPort.js +2 -0
- package/dist/domain/ports/ChunkerPort.js.map +1 -0
- package/dist/domain/ports/DatabaseSessionPort.d.ts +10 -0
- package/dist/domain/ports/DatabaseSessionPort.js +2 -0
- package/dist/domain/ports/DatabaseSessionPort.js.map +1 -0
- package/dist/domain/ports/EmbedderPort.d.ts +14 -0
- package/dist/domain/ports/EmbedderPort.js +2 -0
- package/dist/domain/ports/EmbedderPort.js.map +1 -0
- package/dist/domain/ports/FileManifestRepositoryPort.d.ts +32 -0
- package/dist/domain/ports/FileManifestRepositoryPort.js +2 -0
- package/dist/domain/ports/FileManifestRepositoryPort.js.map +1 -0
- package/dist/domain/ports/GitPort.d.ts +24 -0
- package/dist/domain/ports/GitPort.js +2 -0
- package/dist/domain/ports/GitPort.js.map +1 -0
- package/dist/domain/ports/IndexMaintenancePort.d.ts +58 -0
- package/dist/domain/ports/IndexMaintenancePort.js +2 -0
- package/dist/domain/ports/IndexMaintenancePort.js.map +1 -0
- package/dist/domain/ports/IndexMetadataPort.d.ts +23 -0
- package/dist/domain/ports/IndexMetadataPort.js +2 -0
- package/dist/domain/ports/IndexMetadataPort.js.map +1 -0
- package/dist/domain/ports/LockPort.d.ts +17 -0
- package/dist/domain/ports/LockPort.js +2 -0
- package/dist/domain/ports/LockPort.js.map +1 -0
- package/dist/domain/ports/LoggerPort.d.ts +5 -0
- package/dist/domain/ports/LoggerPort.js +2 -0
- package/dist/domain/ports/LoggerPort.js.map +1 -0
- package/dist/domain/ports/ProjectIndexesPort.d.ts +20 -0
- package/dist/domain/ports/ProjectIndexesPort.js +2 -0
- package/dist/domain/ports/ProjectIndexesPort.js.map +1 -0
- package/dist/domain/ports/ProjectRegistryPort.d.ts +42 -0
- package/dist/domain/ports/ProjectRegistryPort.js +2 -0
- package/dist/domain/ports/ProjectRegistryPort.js.map +1 -0
- package/dist/domain/ports/StateDirectoryPort.d.ts +29 -0
- package/dist/domain/ports/StateDirectoryPort.js +2 -0
- package/dist/domain/ports/StateDirectoryPort.js.map +1 -0
- package/dist/domain/ports/WorkspacePort.d.ts +38 -0
- package/dist/domain/ports/WorkspacePort.js +2 -0
- package/dist/domain/ports/WorkspacePort.js.map +1 -0
- package/dist/domain/project/Branch.d.ts +20 -0
- package/dist/domain/project/Branch.js +33 -0
- package/dist/domain/project/Branch.js.map +1 -0
- package/dist/domain/project/DatabaseLocation.d.ts +32 -0
- package/dist/domain/project/DatabaseLocation.js +35 -0
- package/dist/domain/project/DatabaseLocation.js.map +1 -0
- package/dist/domain/project/IndexMetadata.d.ts +17 -0
- package/dist/domain/project/IndexMetadata.js +2 -0
- package/dist/domain/project/IndexMetadata.js.map +1 -0
- package/dist/domain/project/ModelIdentity.d.ts +58 -0
- package/dist/domain/project/ModelIdentity.js +97 -0
- package/dist/domain/project/ModelIdentity.js.map +1 -0
- package/dist/domain/project/Project.d.ts +17 -0
- package/dist/domain/project/Project.js +21 -0
- package/dist/domain/project/Project.js.map +1 -0
- package/dist/domain/project/ProjectId.d.ts +28 -0
- package/dist/domain/project/ProjectId.js +58 -0
- package/dist/domain/project/ProjectId.js.map +1 -0
- package/dist/domain/project/ProjectLocator.d.ts +112 -0
- package/dist/domain/project/ProjectLocator.js +178 -0
- package/dist/domain/project/ProjectLocator.js.map +1 -0
- package/dist/domain/research/Citation.d.ts +27 -0
- package/dist/domain/research/Citation.js +43 -0
- package/dist/domain/research/Citation.js.map +1 -0
- package/dist/domain/research/EvidenceLedger.d.ts +47 -0
- package/dist/domain/research/EvidenceLedger.js +111 -0
- package/dist/domain/research/EvidenceLedger.js.map +1 -0
- package/dist/domain/research/ResearchTrace.d.ts +19 -0
- package/dist/domain/research/ResearchTrace.js +22 -0
- package/dist/domain/research/ResearchTrace.js.map +1 -0
- package/dist/domain/retrieval/Hit.d.ts +19 -0
- package/dist/domain/retrieval/Hit.js +28 -0
- package/dist/domain/retrieval/Hit.js.map +1 -0
- package/dist/domain/retrieval/HitList.d.ts +35 -0
- package/dist/domain/retrieval/HitList.js +81 -0
- package/dist/domain/retrieval/HitList.js.map +1 -0
- package/dist/domain/retrieval/MissingIndexError.d.ts +11 -0
- package/dist/domain/retrieval/MissingIndexError.js +15 -0
- package/dist/domain/retrieval/MissingIndexError.js.map +1 -0
- package/dist/index.d.ts +43 -33
- package/dist/index.js +32 -215
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/ai/AiSdkChatModel.d.ts +31 -0
- package/dist/infrastructure/ai/AiSdkChatModel.js +137 -0
- package/dist/infrastructure/ai/AiSdkChatModel.js.map +1 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.d.ts +28 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.js +79 -0
- package/dist/infrastructure/ai/AiSdkEmbedder.js.map +1 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.d.ts +21 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.js +40 -0
- package/dist/infrastructure/ai/EmbeddingPrefixes.js.map +1 -0
- package/dist/infrastructure/ai/LmStudioProbe.d.ts +18 -0
- package/dist/infrastructure/ai/LmStudioProbe.js +49 -0
- package/dist/infrastructure/ai/LmStudioProbe.js.map +1 -0
- package/dist/infrastructure/ai/LocalModelReloader.d.ts +21 -0
- package/dist/infrastructure/ai/LocalModelReloader.js +61 -0
- package/dist/infrastructure/ai/LocalModelReloader.js.map +1 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.d.ts +36 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.js +61 -0
- package/dist/infrastructure/ai/LocalRuntimeDetector.js.map +1 -0
- package/dist/infrastructure/ai/ModelRuntime.d.ts +32 -0
- package/dist/infrastructure/ai/ModelRuntime.js +2 -0
- package/dist/infrastructure/ai/ModelRuntime.js.map +1 -0
- package/dist/infrastructure/ai/OllamaProbe.d.ts +21 -0
- package/dist/infrastructure/ai/OllamaProbe.js +69 -0
- package/dist/infrastructure/ai/OllamaProbe.js.map +1 -0
- package/dist/infrastructure/ai/ProviderFailure.d.ts +16 -0
- package/dist/infrastructure/ai/ProviderFailure.js +35 -0
- package/dist/infrastructure/ai/ProviderFailure.js.map +1 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.d.ts +13 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.js +49 -0
- package/dist/infrastructure/ai/ProviderModuleLoader.js.map +1 -0
- package/dist/infrastructure/ai/ProviderRegistry.d.ts +37 -0
- package/dist/infrastructure/ai/ProviderRegistry.js +55 -0
- package/dist/infrastructure/ai/ProviderRegistry.js.map +1 -0
- package/dist/infrastructure/fs/ConfigLoader.d.ts +59 -0
- package/dist/infrastructure/fs/ConfigLoader.js +194 -0
- package/dist/infrastructure/fs/ConfigLoader.js.map +1 -0
- package/dist/infrastructure/fs/DatabaseLocks.d.ts +52 -0
- package/dist/infrastructure/fs/DatabaseLocks.js +92 -0
- package/dist/infrastructure/fs/DatabaseLocks.js.map +1 -0
- package/dist/infrastructure/fs/DiskUsage.d.ts +6 -0
- package/dist/infrastructure/fs/DiskUsage.js +41 -0
- package/dist/infrastructure/fs/DiskUsage.js.map +1 -0
- package/dist/infrastructure/fs/IndexableFileRules.d.ts +33 -0
- package/dist/infrastructure/fs/IndexableFileRules.js +177 -0
- package/dist/infrastructure/fs/IndexableFileRules.js.map +1 -0
- package/dist/infrastructure/fs/Loggers.d.ts +14 -0
- package/dist/infrastructure/fs/Loggers.js +18 -0
- package/dist/infrastructure/fs/Loggers.js.map +1 -0
- package/dist/infrastructure/fs/PidFileLock.d.ts +40 -0
- package/dist/infrastructure/fs/PidFileLock.js +97 -0
- package/dist/infrastructure/fs/PidFileLock.js.map +1 -0
- package/dist/infrastructure/fs/ProjectIndexes.d.ts +8 -0
- package/dist/infrastructure/fs/ProjectIndexes.js +35 -0
- package/dist/infrastructure/fs/ProjectIndexes.js.map +1 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.d.ts +42 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.js +86 -0
- package/dist/infrastructure/fs/ProjectMetadataStore.js.map +1 -0
- package/dist/infrastructure/fs/ProjectRegistry.d.ts +25 -0
- package/dist/infrastructure/fs/ProjectRegistry.js +83 -0
- package/dist/infrastructure/fs/ProjectRegistry.js.map +1 -0
- package/dist/infrastructure/fs/StateDirectory.d.ts +28 -0
- package/dist/infrastructure/fs/StateDirectory.js +71 -0
- package/dist/infrastructure/fs/StateDirectory.js.map +1 -0
- package/dist/infrastructure/fs/Workspace.d.ts +25 -0
- package/dist/infrastructure/fs/Workspace.js +90 -0
- package/dist/infrastructure/fs/Workspace.js.map +1 -0
- package/dist/infrastructure/git/GitClient.d.ts +34 -0
- package/dist/infrastructure/git/GitClient.js +74 -0
- package/dist/infrastructure/git/GitClient.js.map +1 -0
- package/dist/infrastructure/lancedb/ChunkRepository.d.ts +38 -0
- package/dist/infrastructure/lancedb/ChunkRepository.js +166 -0
- package/dist/infrastructure/lancedb/ChunkRepository.js.map +1 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.d.ts +22 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.js +74 -0
- package/dist/infrastructure/lancedb/DatabaseImporter.js.map +1 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.d.ts +34 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.js +137 -0
- package/dist/infrastructure/lancedb/FileManifestRepository.js.map +1 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.d.ts +53 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.js +227 -0
- package/dist/infrastructure/lancedb/IndexMaintenance.js.map +1 -0
- package/dist/infrastructure/lancedb/LanceTables.d.ts +67 -0
- package/dist/infrastructure/lancedb/LanceTables.js +159 -0
- package/dist/infrastructure/lancedb/LanceTables.js.map +1 -0
- package/dist/infrastructure/lancedb/NativeTuning.d.ts +1 -0
- package/dist/infrastructure/lancedb/NativeTuning.js +9 -0
- package/dist/infrastructure/lancedb/NativeTuning.js.map +1 -0
- package/dist/infrastructure/lancedb/RowReplication.d.ts +27 -0
- package/dist/infrastructure/lancedb/RowReplication.js +82 -0
- package/dist/infrastructure/lancedb/RowReplication.js.map +1 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.d.ts +60 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.js +72 -0
- package/dist/infrastructure/lancedb/VectorIndexPolicy.js.map +1 -0
- package/dist/infrastructure/p2p/IndexShare.d.ts +45 -0
- package/dist/infrastructure/p2p/IndexShare.js +160 -0
- package/dist/infrastructure/p2p/IndexShare.js.map +1 -0
- package/dist/infrastructure/p2p/PeerSwarm.d.ts +16 -0
- package/dist/infrastructure/p2p/PeerSwarm.js +41 -0
- package/dist/infrastructure/p2p/PeerSwarm.js.map +1 -0
- package/dist/infrastructure/p2p/SecureChannel.d.ts +60 -0
- package/dist/infrastructure/p2p/SecureChannel.js +71 -0
- package/dist/infrastructure/p2p/SecureChannel.js.map +1 -0
- package/dist/infrastructure/p2p/ShareCode.d.ts +25 -0
- package/dist/infrastructure/p2p/ShareCode.js +304 -0
- package/dist/infrastructure/p2p/ShareCode.js.map +1 -0
- package/dist/infrastructure/process/ProcessRegistry.d.ts +50 -0
- package/dist/infrastructure/process/ProcessRegistry.js +109 -0
- package/dist/infrastructure/process/ProcessRegistry.js.map +1 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.d.ts +45 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.js +159 -0
- package/dist/infrastructure/treesitter/ChunkContextBuilder.js.map +1 -0
- package/dist/infrastructure/treesitter/LanguageCatalog.d.ts +30 -0
- package/dist/{lib/chunker/languages.js → infrastructure/treesitter/LanguageCatalog.js} +65 -41
- package/dist/infrastructure/treesitter/LanguageCatalog.js.map +1 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.d.ts +15 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.js +42 -0
- package/dist/infrastructure/treesitter/SlidingWindowChunker.js.map +1 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.d.ts +42 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.js +163 -0
- package/dist/infrastructure/treesitter/TreeSitterChunker.js.map +1 -0
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +15 -61
- package/dist/mcp.js.map +1 -1
- package/dist/presentation/cli/Cli.d.ts +31 -0
- package/dist/presentation/cli/Cli.js +120 -0
- package/dist/presentation/cli/Cli.js.map +1 -0
- package/dist/presentation/cli/CliOptions.d.ts +18 -0
- package/dist/presentation/cli/CliOptions.js +25 -0
- package/dist/presentation/cli/CliOptions.js.map +1 -0
- package/dist/presentation/cli/CommandContext.d.ts +50 -0
- package/dist/presentation/cli/CommandContext.js +88 -0
- package/dist/presentation/cli/CommandContext.js.map +1 -0
- package/dist/presentation/cli/ConfigTemplate.d.ts +31 -0
- package/dist/presentation/cli/ConfigTemplate.js +83 -0
- package/dist/presentation/cli/ConfigTemplate.js.map +1 -0
- package/dist/presentation/cli/Renderer.d.ts +90 -0
- package/dist/presentation/cli/Renderer.js +290 -0
- package/dist/presentation/cli/Renderer.js.map +1 -0
- package/dist/presentation/cli/commands/AskCommand.d.ts +14 -0
- package/dist/presentation/cli/commands/AskCommand.js +48 -0
- package/dist/presentation/cli/commands/AskCommand.js.map +1 -0
- package/dist/presentation/cli/commands/CompletionsCommand.d.ts +18 -0
- package/dist/presentation/cli/commands/CompletionsCommand.js +96 -0
- package/dist/presentation/cli/commands/CompletionsCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ConfigCommands.d.ts +55 -0
- package/dist/presentation/cli/commands/ConfigCommands.js +204 -0
- package/dist/presentation/cli/commands/ConfigCommands.js.map +1 -0
- package/dist/presentation/cli/commands/IndexCommand.d.ts +18 -0
- package/dist/presentation/cli/commands/IndexCommand.js +54 -0
- package/dist/presentation/cli/commands/IndexCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ProjectsCommand.d.ts +48 -0
- package/dist/presentation/cli/commands/ProjectsCommand.js +240 -0
- package/dist/presentation/cli/commands/ProjectsCommand.js.map +1 -0
- package/dist/presentation/cli/commands/SearchCommand.d.ts +19 -0
- package/dist/presentation/cli/commands/SearchCommand.js +55 -0
- package/dist/presentation/cli/commands/SearchCommand.js.map +1 -0
- package/dist/presentation/cli/commands/ServerCommands.d.ts +13 -0
- package/dist/presentation/cli/commands/ServerCommands.js +40 -0
- package/dist/presentation/cli/commands/ServerCommands.js.map +1 -0
- package/dist/presentation/cli/commands/ShareCommands.d.ts +22 -0
- package/dist/presentation/cli/commands/ShareCommands.js +134 -0
- package/dist/presentation/cli/commands/ShareCommands.js.map +1 -0
- package/dist/presentation/cli/commands/StatusCommand.d.ts +15 -0
- package/dist/presentation/cli/commands/StatusCommand.js +53 -0
- package/dist/presentation/cli/commands/StatusCommand.js.map +1 -0
- package/dist/presentation/mcp/HitFormatter.d.ts +17 -0
- package/dist/presentation/mcp/HitFormatter.js +42 -0
- package/dist/presentation/mcp/HitFormatter.js.map +1 -0
- package/dist/presentation/mcp/IndexWatchController.d.ts +17 -0
- package/dist/presentation/mcp/IndexWatchController.js +31 -0
- package/dist/presentation/mcp/IndexWatchController.js.map +1 -0
- package/dist/presentation/mcp/LmgrepCore.d.ts +66 -0
- package/dist/presentation/mcp/LmgrepCore.js +178 -0
- package/dist/presentation/mcp/LmgrepCore.js.map +1 -0
- package/dist/presentation/mcp/McpServer.d.ts +18 -0
- package/dist/presentation/mcp/McpServer.js +63 -0
- package/dist/presentation/mcp/McpServer.js.map +1 -0
- package/dist/presentation/mcp/ToolDescriptions.d.ts +40 -0
- package/dist/presentation/mcp/ToolDescriptions.js +85 -0
- package/dist/presentation/mcp/ToolDescriptions.js.map +1 -0
- package/package.json +84 -63
- package/dist/lib/build.d.ts +0 -7
- package/dist/lib/build.js +0 -284
- package/dist/lib/build.js.map +0 -1
- package/dist/lib/chunker/context.d.ts +0 -21
- package/dist/lib/chunker/context.js +0 -131
- package/dist/lib/chunker/context.js.map +0 -1
- package/dist/lib/chunker/index.d.ts +0 -7
- package/dist/lib/chunker/index.js +0 -150
- package/dist/lib/chunker/index.js.map +0 -1
- package/dist/lib/chunker/languages.d.ts +0 -15
- package/dist/lib/chunker/languages.js.map +0 -1
- package/dist/lib/config.d.ts +0 -12
- package/dist/lib/config.js +0 -83
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/embedder.d.ts +0 -55
- package/dist/lib/embedder.js +0 -221
- package/dist/lib/embedder.js.map +0 -1
- package/dist/lib/p2p.d.ts +0 -32
- package/dist/lib/p2p.js +0 -281
- package/dist/lib/p2p.js.map +0 -1
- package/dist/lib/providers.d.ts +0 -1
- package/dist/lib/providers.js +0 -41
- package/dist/lib/providers.js.map +0 -1
- package/dist/lib/repair.d.ts +0 -10
- package/dist/lib/repair.js +0 -57
- package/dist/lib/repair.js.map +0 -1
- package/dist/lib/scanner.d.ts +0 -34
- package/dist/lib/scanner.js +0 -242
- package/dist/lib/scanner.js.map +0 -1
- package/dist/lib/search-tool.d.ts +0 -47
- package/dist/lib/search-tool.js +0 -239
- package/dist/lib/search-tool.js.map +0 -1
- package/dist/lib/serve.d.ts +0 -11
- package/dist/lib/serve.js +0 -127
- package/dist/lib/serve.js.map +0 -1
- package/dist/lib/store.d.ts +0 -177
- package/dist/lib/store.js +0 -825
- package/dist/lib/store.js.map +0 -1
- package/dist/lib/types.d.ts +0 -129
- package/dist/lib/types.js +0 -13
- package/dist/lib/types.js.map +0 -1
|
@@ -0,0 +1,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,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE5D,YAA6B,OAA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AAc,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
|
+
}
|
|
@@ -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,GAA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|
|
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;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACG;IAA7B,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,QAAQ,CAAC,OAAgB;QACxB,UAAU,CAAC,MAAM,CAChB,OAAO;aACL,OAAO,CAAC,OAAO,CAAC;aAChB,WAAW,CAAC,iDAAiD,CAAC,CAChE,CAAC,MAAM,CAAC,KAAK,EAAE,OAAsB,EAAE,EAAE;YACzC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAChD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;YAC5B,+DAA+D;YAC/D,mBAAmB;YACnB,MAAM,QAAQ,GAAG,GAAS,EAAE;gBAC3B,IAAI,EAAE,CAAC;gBACP,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,CAAC,CAAC;YACF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,MAAM,CAChB,OAAO;aACL,OAAO,CAAC,KAAK,CAAC;aACd,WAAW,CAAC,wCAAwC,CAAC,CACvD,CAAC,MAAM,CAAC,KAAK,EAAE,OAAsB,EAAE,EAAE;YACzC,mEAAmE;YACnE,yDAAyD;YACzD,MAAM,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;YAC/B,IAAI,MAAM;gBAAE,OAAO,CAAC,GAAG,CAAC,eAAe,GAAG,MAAM,CAAC;YACjD,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,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":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,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,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,gDAAgD,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAYrE;;;;;;GAMG;AACH,MAAM,OAAO,aAAa;IACI;IAA7B,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,QAAQ,CAAC,OAAgB;QACxB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC7B,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAEO,cAAc,CAA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AqE;IAC7D,OAAO;QACd,MAAM,KAAK,GAAG,IAAI,cAAc,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,IAAI,cAAc,CACjC,IAAI,SAAS,EAAE,EACf,KAAK,EACL,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAC9B,MAAM,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":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAS9C;;;;;;GAMG;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,QAAQ,CAAC;aACjB,WAAW,CAAC,0CAA0C,CAAC;aACvD,MAAM,CAAC,eAAe,EAAE,uCAAuC,CAAC;aAChE,MAAM,CAAC,eAAe,EAAE,6CAA6C,CAAC;aACtE,MAAM,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAC1C,CAAC,MAAM,CAAC,CAAC,OAAsB,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,CAAC;IAEO,KAAK,CAAC,GAAG,CAAC,OAAsB;QACvC,MAAM,SAAS,GAAG,IAAI,eAAe,CACpC,IAAI,cAAc,EAAE,CACpB,CAAC,eAAe,EAAE,CAAC;QAEpB,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE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