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
package/dist/mcp.js
CHANGED
|
@@ -1,79 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
process.title = "lmgrep-mcp";
|
|
3
|
-
// Must come first — sets TOKIO/RAYON/UV thread caps before LanceDB native
|
|
3
|
+
// Must come first — sets TOKIO/RAYON/UV thread caps before the LanceDB native
|
|
4
4
|
// binding initializes its runtime.
|
|
5
|
-
import "./
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
const searchTool = server.tool("search", core.buildSearchDescription(), {
|
|
16
|
-
query: z.string().describe(core.searchParams.query.description),
|
|
17
|
-
limit: z
|
|
18
|
-
.number()
|
|
19
|
-
.optional()
|
|
20
|
-
.default(core.searchParams.limit.default)
|
|
21
|
-
.describe(core.searchParams.limit.description),
|
|
22
|
-
filePrefix: z
|
|
23
|
-
.string()
|
|
24
|
-
.optional()
|
|
25
|
-
.describe(core.searchParams.filePrefix.description),
|
|
26
|
-
type: z
|
|
27
|
-
.array(z.string())
|
|
28
|
-
.optional()
|
|
29
|
-
.describe(core.searchParams.type.description),
|
|
30
|
-
language: z
|
|
31
|
-
.array(z.string())
|
|
32
|
-
.optional()
|
|
33
|
-
.describe(core.searchParams.language.description),
|
|
34
|
-
project: z
|
|
35
|
-
.string()
|
|
36
|
-
.optional()
|
|
37
|
-
.describe(core.searchParams.project.description),
|
|
38
|
-
}, async (args) => {
|
|
39
|
-
const result = await core.executeSearch(args);
|
|
40
|
-
return {
|
|
41
|
-
content: [{ type: "text", text: result.text }],
|
|
42
|
-
...(result.isError ? { isError: true } : {}),
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
server.tool("facet", core.facetDescription, {
|
|
46
|
-
query: z.string().describe(core.facetParam.description),
|
|
47
|
-
}, async (args) => {
|
|
48
|
-
const result = await core.executeFacet(args);
|
|
49
|
-
return {
|
|
50
|
-
content: [{ type: "text", text: result.text }],
|
|
51
|
-
...(result.isError ? { isError: true } : {}),
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
server.tool("list_other_indexed_projects", core.listProjectsDescription, {}, async () => {
|
|
55
|
-
const result = await core.executeListProjects();
|
|
56
|
-
return { content: [{ type: "text", text: result.text }] };
|
|
57
|
-
});
|
|
58
|
-
core.onHealthChange(() => {
|
|
59
|
-
searchTool.update({ description: core.buildSearchDescription() });
|
|
60
|
-
});
|
|
61
|
-
core.start();
|
|
5
|
+
import "./infrastructure/lancedb/NativeTuning.js";
|
|
6
|
+
import { LmgrepCore } from "./presentation/mcp/LmgrepCore.js";
|
|
7
|
+
import { LmgrepMcpServer } from "./presentation/mcp/McpServer.js";
|
|
8
|
+
const core = await LmgrepCore.open({
|
|
9
|
+
cwd: process.cwd(),
|
|
10
|
+
database: process.env.LMGREP_DATABASE || undefined,
|
|
11
|
+
});
|
|
12
|
+
const shutdown = () => {
|
|
13
|
+
core.dispose().finally(() => process.exit(0));
|
|
14
|
+
};
|
|
62
15
|
process.on("exit", () => {
|
|
63
16
|
core.dispose().catch(() => { });
|
|
64
17
|
});
|
|
65
|
-
process.on("SIGINT",
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
process.on("SIGTERM", () => {
|
|
69
|
-
core.dispose().finally(() => process.exit(0));
|
|
70
|
-
});
|
|
71
|
-
async function main() {
|
|
72
|
-
const transport = new StdioServerTransport();
|
|
73
|
-
await server.connect(transport);
|
|
74
|
-
}
|
|
75
|
-
main().catch((err) => {
|
|
76
|
-
console.error("lmgrep MCP server error:", err);
|
|
77
|
-
process.exit(1);
|
|
78
|
-
});
|
|
18
|
+
process.on("SIGINT", shutdown);
|
|
19
|
+
process.on("SIGTERM", shutdown);
|
|
20
|
+
await new LmgrepMcpServer(core).serve();
|
|
79
21
|
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":";AACA,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC;AAE7B,
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":";AACA,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC;AAE7B,8EAA8E;AAC9E,mCAAmC;AACnC,OAAO,0CAA0C,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC;IAClC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;IAClB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,SAAS;CAClD,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,GAAS,EAAE;IAC3B,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC;AACF,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;IACvB,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAEhC,MAAM,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CommandContext } from "./CommandContext.js";
|
|
2
|
+
/**
|
|
3
|
+
* Assembles and runs the command-line interface.
|
|
4
|
+
*
|
|
5
|
+
* Two things here are deliberate. A bare `lmgrep <words>` searches, because
|
|
6
|
+
* searching is what lmgrep is for and it should not cost a subcommand. And the
|
|
7
|
+
* help is grouped, because a flat list of a dozen commands says nothing about
|
|
8
|
+
* which two anyone actually needs — the first group is the whole product, and
|
|
9
|
+
* the rest is setup you do once.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Cli {
|
|
12
|
+
private readonly context;
|
|
13
|
+
/** Help grouping, by command name. Order here is order in `--help`. */
|
|
14
|
+
private static readonly GROUPS;
|
|
15
|
+
private readonly program;
|
|
16
|
+
constructor(context?: CommandContext);
|
|
17
|
+
run(argv?: string[]): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Treat a leading word that is not a command as the start of a query.
|
|
20
|
+
*
|
|
21
|
+
* The ambiguity is real but small: `lmgrep status` is the command, not a
|
|
22
|
+
* search for the word "status". Anything of more than one word, and
|
|
23
|
+
* anything that is not a command name, searches — which covers every query
|
|
24
|
+
* a person would actually type.
|
|
25
|
+
*/
|
|
26
|
+
private withImplicitSearch;
|
|
27
|
+
private commandNames;
|
|
28
|
+
private group;
|
|
29
|
+
private static looksLikeStdioLaunch;
|
|
30
|
+
private commands;
|
|
31
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { CommandContext } from "./CommandContext.js";
|
|
3
|
+
import { AskCommand } from "./commands/AskCommand.js";
|
|
4
|
+
import { CompletionsCommand } from "./commands/CompletionsCommand.js";
|
|
5
|
+
import { ConfigCommands } from "./commands/ConfigCommands.js";
|
|
6
|
+
import { IndexCommand } from "./commands/IndexCommand.js";
|
|
7
|
+
import { ProjectsCommand } from "./commands/ProjectsCommand.js";
|
|
8
|
+
import { SearchCommand } from "./commands/SearchCommand.js";
|
|
9
|
+
import { ServerCommands } from "./commands/ServerCommands.js";
|
|
10
|
+
import { ShareCommands } from "./commands/ShareCommands.js";
|
|
11
|
+
import { StatusCommand } from "./commands/StatusCommand.js";
|
|
12
|
+
/**
|
|
13
|
+
* Assembles and runs the command-line interface.
|
|
14
|
+
*
|
|
15
|
+
* Two things here are deliberate. A bare `lmgrep <words>` searches, because
|
|
16
|
+
* searching is what lmgrep is for and it should not cost a subcommand. And the
|
|
17
|
+
* help is grouped, because a flat list of a dozen commands says nothing about
|
|
18
|
+
* which two anyone actually needs — the first group is the whole product, and
|
|
19
|
+
* the rest is setup you do once.
|
|
20
|
+
*/
|
|
21
|
+
export class Cli {
|
|
22
|
+
context;
|
|
23
|
+
/** Help grouping, by command name. Order here is order in `--help`. */
|
|
24
|
+
static GROUPS = [
|
|
25
|
+
["Searching:", ["search", "ask"]],
|
|
26
|
+
["Your projects:", ["index", "status", "projects"]],
|
|
27
|
+
["Setup:", ["init", "config", "mcp", "completions"]],
|
|
28
|
+
["Other:", ["serve", "share", "import"]],
|
|
29
|
+
];
|
|
30
|
+
program = new Command();
|
|
31
|
+
constructor(context = new CommandContext()) {
|
|
32
|
+
this.context = context;
|
|
33
|
+
this.program
|
|
34
|
+
.name("lmgrep")
|
|
35
|
+
.description("Semantic code search, powered by a local embedding model")
|
|
36
|
+
.version("0.1.0")
|
|
37
|
+
.showHelpAfterError()
|
|
38
|
+
.addHelpText("after", "\nA bare query searches: lmgrep how are webhooks authenticated" +
|
|
39
|
+
"\nFirst time here: lmgrep init → lmgrep index");
|
|
40
|
+
for (const command of this.commands())
|
|
41
|
+
command.register(this.program);
|
|
42
|
+
this.group();
|
|
43
|
+
}
|
|
44
|
+
async run(argv = process.argv) {
|
|
45
|
+
// With no arguments and both streams piped, this was launched as an
|
|
46
|
+
// MCP server over stdio rather than by a human at a terminal.
|
|
47
|
+
if (Cli.looksLikeStdioLaunch(argv)) {
|
|
48
|
+
await import("../../mcp.js");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
await this.program.parseAsync(this.withImplicitSearch(argv));
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
// Every failure reaching here is a user-facing condition — no
|
|
56
|
+
// index, an unreachable provider, incompatible embeddings — not a
|
|
57
|
+
// defect. Report the message and set an exit code; a stack trace
|
|
58
|
+
// would only bury it. Guarding once here means no command can
|
|
59
|
+
// forget to.
|
|
60
|
+
this.context.fail(err);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Treat a leading word that is not a command as the start of a query.
|
|
65
|
+
*
|
|
66
|
+
* The ambiguity is real but small: `lmgrep status` is the command, not a
|
|
67
|
+
* search for the word "status". Anything of more than one word, and
|
|
68
|
+
* anything that is not a command name, searches — which covers every query
|
|
69
|
+
* a person would actually type.
|
|
70
|
+
*/
|
|
71
|
+
withImplicitSearch(argv) {
|
|
72
|
+
const rest = argv.slice(2);
|
|
73
|
+
const first = rest[0];
|
|
74
|
+
if (!first || first.startsWith("-"))
|
|
75
|
+
return argv;
|
|
76
|
+
if (this.commandNames().has(first))
|
|
77
|
+
return argv;
|
|
78
|
+
return [...argv.slice(0, 2), "search", ...rest];
|
|
79
|
+
}
|
|
80
|
+
commandNames() {
|
|
81
|
+
const names = new Set(["help"]);
|
|
82
|
+
for (const command of this.program.commands) {
|
|
83
|
+
names.add(command.name());
|
|
84
|
+
for (const alias of command.aliases())
|
|
85
|
+
names.add(alias);
|
|
86
|
+
}
|
|
87
|
+
return names;
|
|
88
|
+
}
|
|
89
|
+
group() {
|
|
90
|
+
const groupOf = new Map();
|
|
91
|
+
for (const [group, names] of Cli.GROUPS) {
|
|
92
|
+
for (const name of names)
|
|
93
|
+
groupOf.set(name, group);
|
|
94
|
+
}
|
|
95
|
+
for (const command of this.program.commands) {
|
|
96
|
+
const group = groupOf.get(command.name());
|
|
97
|
+
if (group)
|
|
98
|
+
command.helpGroup(group);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
static looksLikeStdioLaunch(argv) {
|
|
102
|
+
return (argv.slice(2).length === 0 &&
|
|
103
|
+
!process.stdin.isTTY &&
|
|
104
|
+
!process.stdout.isTTY);
|
|
105
|
+
}
|
|
106
|
+
commands() {
|
|
107
|
+
return [
|
|
108
|
+
new SearchCommand(this.context),
|
|
109
|
+
new AskCommand(this.context),
|
|
110
|
+
new IndexCommand(this.context),
|
|
111
|
+
new StatusCommand(this.context),
|
|
112
|
+
new ProjectsCommand(this.context),
|
|
113
|
+
new ConfigCommands(this.context),
|
|
114
|
+
new ServerCommands(this.context),
|
|
115
|
+
new ShareCommands(this.context),
|
|
116
|
+
new CompletionsCommand(this.context),
|
|
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,CAAC,KAAK,CACrB,CAAC;IACH,CAAC;IAEO,QAAQ;QACf,OAAO;YACN,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC;YAC/B,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;YAC5B,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;YAC9B,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC;YAC/B,IAAI,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;YACjC,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC;YAChC,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC;YAChC,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC;YAC/B,IAAI,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC;SACpC,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
/** The one option every command shares, and its help text. */
|
|
3
|
+
export declare class CliOptions {
|
|
4
|
+
/**
|
|
5
|
+
* `--in` replaced three overlapping options — `--project`, `--across` and
|
|
6
|
+
* `--database` — which were three spellings of "somewhere other than here".
|
|
7
|
+
*
|
|
8
|
+
* A value with a separator is a project directory, because that is what
|
|
9
|
+
* people have to hand; a bare name is a standalone index kept in the state
|
|
10
|
+
* directory, for corpora that are not repositories.
|
|
11
|
+
*/
|
|
12
|
+
static readonly TARGET: string;
|
|
13
|
+
static target(command: Command): Command;
|
|
14
|
+
/** Commander calls this once per occurrence of a repeatable option. */
|
|
15
|
+
private static collect;
|
|
16
|
+
/** The single target a write command operates on, if any. */
|
|
17
|
+
static single(targets: string[] | undefined): string | undefined;
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The one option every command shares, and its help text. */
|
|
2
|
+
export class CliOptions {
|
|
3
|
+
/**
|
|
4
|
+
* `--in` replaced three overlapping options — `--project`, `--across` and
|
|
5
|
+
* `--database` — which were three spellings of "somewhere other than here".
|
|
6
|
+
*
|
|
7
|
+
* A value with a separator is a project directory, because that is what
|
|
8
|
+
* people have to hand; a bare name is a standalone index kept in the state
|
|
9
|
+
* directory, for corpora that are not repositories.
|
|
10
|
+
*/
|
|
11
|
+
static TARGET = "Project directory, or the name of a standalone index. " +
|
|
12
|
+
"Repeat to search several at once; use `.` to include the current project.";
|
|
13
|
+
static target(command) {
|
|
14
|
+
return command.option("--in <project-or-name>", CliOptions.TARGET, CliOptions.collect, []);
|
|
15
|
+
}
|
|
16
|
+
/** Commander calls this once per occurrence of a repeatable option. */
|
|
17
|
+
static collect(value, previous) {
|
|
18
|
+
return [...previous, value];
|
|
19
|
+
}
|
|
20
|
+
/** The single target a write command operates on, if any. */
|
|
21
|
+
static single(targets) {
|
|
22
|
+
return targets && targets.length > 0 ? targets[0] : undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=CliOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CliOptions.js","sourceRoot":"","sources":["../../../src/presentation/cli/CliOptions.ts"],"names":[],"mappings":"AAEA,8DAA8D;AAC9D,MAAM,OAAO,UAAU;IACtB;;;;;;;OAOG;IACH,MAAM,CAAU,MAAM,GACrB,wDAAwD;QACxD,2EAA2E,CAAC;IAE7E,MAAM,CAAC,MAAM,CAAC,OAAgB;QAC7B,OAAO,OAAO,CAAC,MAAM,CACpB,wBAAwB,EACxB,UAAU,CAAC,MAAM,EACjB,UAAU,CAAC,OAAO,EAClB,EAAc,CACd,CAAC;IACH,CAAC;IAED,uEAAuE;IAC/D,MAAM,CAAC,OAAO,CAAC,KAAa,EAAE,QAAkB;QACvD,OAAO,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,6DAA6D;IAC7D,MAAM,CAAC,MAAM,CAAC,OAA6B;QAC1C,OAAO,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/D,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Lmgrep } from "../../application/Lmgrep.js";
|
|
2
|
+
import { LmgrepFactory } from "../../application/LmgrepFactory.js";
|
|
3
|
+
import { Renderer } from "./Renderer.js";
|
|
4
|
+
/** Options every command accepts. */
|
|
5
|
+
export interface GlobalOptions {
|
|
6
|
+
/** Repeatable `--in` targets. Write commands use only the first. */
|
|
7
|
+
in?: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Shared plumbing for CLI commands: opening an Lmgrep, closing it again, and
|
|
11
|
+
* turning a thrown error into an exit code.
|
|
12
|
+
*
|
|
13
|
+
* Commands run through {@link withLmgrep} rather than opening their own, so no
|
|
14
|
+
* command can forget to close the database — a leaked LanceDB connection keeps
|
|
15
|
+
* a native runtime and its buffers alive for the life of the process.
|
|
16
|
+
*/
|
|
17
|
+
export declare class CommandContext {
|
|
18
|
+
readonly renderer: Renderer;
|
|
19
|
+
private readonly factory;
|
|
20
|
+
constructor(renderer?: Renderer, factory?: LmgrepFactory);
|
|
21
|
+
get cwd(): string;
|
|
22
|
+
open(options: GlobalOptions): Promise<Lmgrep>;
|
|
23
|
+
/**
|
|
24
|
+
* Split `--in` values into the three things they can mean.
|
|
25
|
+
*
|
|
26
|
+
* The first path-like value replaces the working directory — "act as if I
|
|
27
|
+
* were there" — which is what makes `status --in ../other` and
|
|
28
|
+
* `search --in ../other` mean the obvious thing without a second flag. Any
|
|
29
|
+
* further paths are additional projects to search. A bare name selects a
|
|
30
|
+
* standalone index instead.
|
|
31
|
+
*/
|
|
32
|
+
static targets(options: GlobalOptions): {
|
|
33
|
+
cwd: string;
|
|
34
|
+
name?: string;
|
|
35
|
+
across: string[];
|
|
36
|
+
};
|
|
37
|
+
/** Open, run, and always close — even when `run` throws. */
|
|
38
|
+
withLmgrep<T>(options: GlobalOptions, run: (lmgrep: Lmgrep) => Promise<T>): Promise<T | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Report a failure the way a CLI should: message on stderr, non-zero exit,
|
|
41
|
+
* no stack trace. Errors reaching here are user-facing conditions (no
|
|
42
|
+
* index, bad path, unreachable provider), not defects. Called once from
|
|
43
|
+
* {@link Cli.run} so no command can forget to.
|
|
44
|
+
*/
|
|
45
|
+
fail(error: unknown): void;
|
|
46
|
+
static isPathLike(value: string): boolean;
|
|
47
|
+
static integer(value: string | undefined, fallback: number): number;
|
|
48
|
+
/** Parse a comma-separated option into trimmed values. */
|
|
49
|
+
static list(value?: string): string[] | undefined;
|
|
50
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { LmgrepFactory } from "../../application/LmgrepFactory.js";
|
|
3
|
+
import { Renderer } from "./Renderer.js";
|
|
4
|
+
/**
|
|
5
|
+
* Shared plumbing for CLI commands: opening an Lmgrep, closing it again, and
|
|
6
|
+
* turning a thrown error into an exit code.
|
|
7
|
+
*
|
|
8
|
+
* Commands run through {@link withLmgrep} rather than opening their own, so no
|
|
9
|
+
* command can forget to close the database — a leaked LanceDB connection keeps
|
|
10
|
+
* a native runtime and its buffers alive for the life of the process.
|
|
11
|
+
*/
|
|
12
|
+
export class CommandContext {
|
|
13
|
+
renderer;
|
|
14
|
+
factory;
|
|
15
|
+
constructor(renderer = new Renderer(), factory = new LmgrepFactory()) {
|
|
16
|
+
this.renderer = renderer;
|
|
17
|
+
this.factory = factory;
|
|
18
|
+
}
|
|
19
|
+
get cwd() {
|
|
20
|
+
return process.cwd();
|
|
21
|
+
}
|
|
22
|
+
async open(options) {
|
|
23
|
+
const targets = CommandContext.targets(options);
|
|
24
|
+
return this.factory.open({
|
|
25
|
+
cwd: targets.cwd,
|
|
26
|
+
database: targets.name,
|
|
27
|
+
onWarning: (message) => this.renderer.error(message),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Split `--in` values into the three things they can mean.
|
|
32
|
+
*
|
|
33
|
+
* The first path-like value replaces the working directory — "act as if I
|
|
34
|
+
* were there" — which is what makes `status --in ../other` and
|
|
35
|
+
* `search --in ../other` mean the obvious thing without a second flag. Any
|
|
36
|
+
* further paths are additional projects to search. A bare name selects a
|
|
37
|
+
* standalone index instead.
|
|
38
|
+
*/
|
|
39
|
+
static targets(options) {
|
|
40
|
+
const values = options.in ?? [];
|
|
41
|
+
const paths = values.filter((v) => CommandContext.isPathLike(v));
|
|
42
|
+
const name = values.find((v) => !CommandContext.isPathLike(v));
|
|
43
|
+
return {
|
|
44
|
+
cwd: paths[0] ? resolve(process.cwd(), paths[0]) : process.cwd(),
|
|
45
|
+
name,
|
|
46
|
+
across: paths.slice(1),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Open, run, and always close — even when `run` throws. */
|
|
50
|
+
async withLmgrep(options, run) {
|
|
51
|
+
const lmgrep = await this.open(options);
|
|
52
|
+
try {
|
|
53
|
+
return await run(lmgrep);
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
await lmgrep.close();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Report a failure the way a CLI should: message on stderr, non-zero exit,
|
|
61
|
+
* no stack trace. Errors reaching here are user-facing conditions (no
|
|
62
|
+
* index, bad path, unreachable provider), not defects. Called once from
|
|
63
|
+
* {@link Cli.run} so no command can forget to.
|
|
64
|
+
*/
|
|
65
|
+
fail(error) {
|
|
66
|
+
this.renderer.error(error instanceof Error ? error.message : String(error));
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
}
|
|
69
|
+
static isPathLike(value) {
|
|
70
|
+
return (value.includes("/") ||
|
|
71
|
+
value.includes("\\") ||
|
|
72
|
+
value === "." ||
|
|
73
|
+
value === "..");
|
|
74
|
+
}
|
|
75
|
+
static integer(value, fallback) {
|
|
76
|
+
if (value === undefined)
|
|
77
|
+
return fallback;
|
|
78
|
+
const n = Number.parseInt(value, 10);
|
|
79
|
+
return Number.isNaN(n) ? fallback : n;
|
|
80
|
+
}
|
|
81
|
+
/** Parse a comma-separated option into trimmed values. */
|
|
82
|
+
static list(value) {
|
|
83
|
+
if (!value)
|
|
84
|
+
return undefined;
|
|
85
|
+
return value.split(",").map((s) => s.trim());
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=CommandContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandContext.js","sourceRoot":"","sources":["../../../src/presentation/cli/CommandContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQzC;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IAEhB;IACQ;IAFlB,YACU,WAAqB,IAAI,QAAQ,EAAE,EAC3B,UAAyB,IAAI,aAAa,EAAE;QADpD,aAAQ,GAAR,QAAQ,CAA2B;QAC3B,YAAO,GAAP,OAAO,CAAqC;IAC3D,CAAC;IAEJ,IAAI,GAAG;QACN,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAsB;QAChC,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACxB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,QAAQ,EAAE,OAAO,CAAC,IAAI;YACtB,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;SACpD,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,OAAO,CAAC,OAAsB;QAK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K,CAAC,QAAQ,CAAC,IAAI,CAAC;YACpB,KAAK,KAAK,GAAG;YACb,KAAK,KAAK,IAAI,CACd,CAAC;IACH,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,KAAyB,EAAE,QAAgB;QACzD,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAC;QACzC,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,0DAA0D;IAC1D,MAAM,CAAC,IAAI,CAAC,KAAc;QACzB,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;CACD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Everything `init` managed to work out about the local setup. */
|
|
2
|
+
export interface DetectedSettings {
|
|
3
|
+
model?: string;
|
|
4
|
+
baseURL?: string;
|
|
5
|
+
providerPackage?: string;
|
|
6
|
+
local?: boolean;
|
|
7
|
+
chatModel?: string;
|
|
8
|
+
prefixes?: {
|
|
9
|
+
query: string;
|
|
10
|
+
document: string;
|
|
11
|
+
family?: string;
|
|
12
|
+
};
|
|
13
|
+
/** Deliberate tuning from an existing config, carried through untouched. */
|
|
14
|
+
batchSize?: number;
|
|
15
|
+
maxTokens?: number;
|
|
16
|
+
dimensions?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The starter `config.yml` written by `lmgrep init`.
|
|
20
|
+
*
|
|
21
|
+
* Every optional setting is present but commented out. That is deliberate: it
|
|
22
|
+
* doubles as the reference documentation a user actually reads, so an option
|
|
23
|
+
* they never knew existed is one line away rather than in a README.
|
|
24
|
+
*
|
|
25
|
+
* Only machine settings appear here. `ignore` and `extensions` describe a
|
|
26
|
+
* repository and belong in its `.lmgrep.yml`, where they can be committed and
|
|
27
|
+
* mean the same thing on every machine that checks it out.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ConfigTemplate {
|
|
30
|
+
static render(detected?: DetectedSettings): string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The starter `config.yml` written by `lmgrep init`.
|
|
3
|
+
*
|
|
4
|
+
* Every optional setting is present but commented out. That is deliberate: it
|
|
5
|
+
* doubles as the reference documentation a user actually reads, so an option
|
|
6
|
+
* they never knew existed is one line away rather than in a README.
|
|
7
|
+
*
|
|
8
|
+
* Only machine settings appear here. `ignore` and `extensions` describe a
|
|
9
|
+
* repository and belong in its `.lmgrep.yml`, where they can be committed and
|
|
10
|
+
* mean the same thing on every machine that checks it out.
|
|
11
|
+
*/
|
|
12
|
+
export class ConfigTemplate {
|
|
13
|
+
static render(detected) {
|
|
14
|
+
const modelLine = detected?.model
|
|
15
|
+
? `model: ${detected.model}`
|
|
16
|
+
: "# model: ollama:nomic-embed-text # ← set your model here";
|
|
17
|
+
const baseURLLine = detected?.baseURL
|
|
18
|
+
? `baseURL: ${detected.baseURL}`
|
|
19
|
+
: "# baseURL: http://localhost:11434/v1";
|
|
20
|
+
const providerLine = detected?.providerPackage
|
|
21
|
+
? `provider: "${detected.providerPackage}"`
|
|
22
|
+
: '# provider: "@ai-sdk/openai-compatible"';
|
|
23
|
+
const localLine = detected?.local ? "local: true" : "# local: true";
|
|
24
|
+
// Asymmetric models need these and fail silently without them, so they
|
|
25
|
+
// are written out rather than left commented.
|
|
26
|
+
const prefixLines = detected?.prefixes
|
|
27
|
+
? [
|
|
28
|
+
detected.prefixes.family
|
|
29
|
+
? `# ${detected.prefixes.family} models are asymmetric — these prefixes are required.`
|
|
30
|
+
: "# Prefixes required by this model.",
|
|
31
|
+
`queryPrefix: ${JSON.stringify(detected.prefixes.query)}`,
|
|
32
|
+
`documentPrefix: ${JSON.stringify(detected.prefixes.document)}`,
|
|
33
|
+
].join("\n")
|
|
34
|
+
: [
|
|
35
|
+
'# queryPrefix: "search_query: "',
|
|
36
|
+
'# documentPrefix: "search_document: "',
|
|
37
|
+
].join("\n");
|
|
38
|
+
const chatLine = detected?.chatModel
|
|
39
|
+
? `chatModel: ${detected.chatModel}`
|
|
40
|
+
: "# chatModel: lmstudio:qwen/qwen3.5-9b";
|
|
41
|
+
return `# lmgrep — this machine's inference setup.
|
|
42
|
+
#
|
|
43
|
+
# These settings say which local models to use and where they listen. They are
|
|
44
|
+
# not per project: each model keeps its own index, so changing \`model\` here
|
|
45
|
+
# selects a different database rather than invalidating an existing one.
|
|
46
|
+
#
|
|
47
|
+
# Per-repository settings (ignore patterns, file extensions) go in a
|
|
48
|
+
# .lmgrep.yml inside that repository.
|
|
49
|
+
#
|
|
50
|
+
# Quick start with Ollama:
|
|
51
|
+
# 1. Install: curl -fsSL https://ollama.com/install.sh | sh
|
|
52
|
+
# 2. Pull a model: ollama pull nomic-embed-text
|
|
53
|
+
# 3. Run: lmgrep init --force (to auto-detect)
|
|
54
|
+
|
|
55
|
+
# Embedding model in "provider:model" format
|
|
56
|
+
${modelLine}
|
|
57
|
+
|
|
58
|
+
# Base URL for the embedding API
|
|
59
|
+
${baseURLLine}
|
|
60
|
+
|
|
61
|
+
# AI SDK package providing the model
|
|
62
|
+
${providerLine}
|
|
63
|
+
|
|
64
|
+
# Provider runs locally, so health checks may probe it freely
|
|
65
|
+
${localLine}
|
|
66
|
+
|
|
67
|
+
# Batch size for embedding API calls
|
|
68
|
+
batchSize: ${detected?.batchSize ?? 100}
|
|
69
|
+
|
|
70
|
+
${prefixLines}
|
|
71
|
+
|
|
72
|
+
# Generative model for \`lmgrep ask\`. Optional — without it, \`ask\` is hidden.
|
|
73
|
+
${chatLine}
|
|
74
|
+
|
|
75
|
+
# Optional: embedding dimensions (if model supports it)
|
|
76
|
+
${detected?.dimensions ? `dimensions: ${detected.dimensions}` : "# dimensions: 384"}
|
|
77
|
+
|
|
78
|
+
# Optional: max tokens per chunk (estimated at 4 chars/token)
|
|
79
|
+
${detected?.maxTokens ? `maxTokens: ${detected.maxTokens}` : "# maxTokens: 8192"}
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=ConfigTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigTemplate.js","sourceRoot":"","sources":["../../../src/presentation/cli/ConfigTemplate.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAc;IAC1B,MAAM,CAAC,MAAM,CAAC,QAA2B;QACxC,MAAM,SAAS,GAAG,QAAQ,EAAE,KAAK;YAChC,CAAC,CAAC,UAAU,QAAQ,CAAC,KAAK,EAAE;YAC5B,CAAC,CAAC,2DAA2D,CAAC;QAC/D,MAAM,WAAW,GAAG,QAAQ,EAAE,OAAO;YACpC,CAAC,CAAC,YAAY,QAAQ,CAAC,OAAO,EAAE;YAChC,CAAC,CAAC,sCAAsC,CAAC;QAC1C,MAAM,YAAY,GAAG,QAAQ,EAAE,eAAe;YAC7C,CAAC,CAAC,cAAc,QAAQ,CAAC,eAAe,GAAG;YAC3C,CAAC,CAAC,yCAAyC,CAAC;QAC7C,MAAM,SAAS,GAAG,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC;QAEpE,uEAAuE;QACvE,8CAA8C;QAC9C,MAAM,WAAW,GAAG,QAAQ,EAAE,QAAQ;YACrC,CAAC,CAAC;gBACA,QAAQ,CAAC,QAAQ,CAAC,MAAM;oBACvB,CAAC,CAAC,KAAK,QAAQ,CAAC,QAAQ,CAAC,MAAM,uDAAuD;oBACtF,CAAC,CAAC,oCAAoC;gBACvC,gBAAgB,IAAI,CAAC,SAA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