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
package/package.json
CHANGED
|
@@ -1,65 +1,86 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
2
|
+
"name": "lmgrep",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Semantic code search with any AI embedding provider",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"lmgrep": "./dist/cli.js",
|
|
8
|
+
"lmgrep-mcp": "./dist/mcp.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"start": "node dist/cli.js",
|
|
14
|
+
"check": "biome check --write .",
|
|
15
|
+
"lint": "biome lint ."
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"semantic-search",
|
|
19
|
+
"code-search",
|
|
20
|
+
"embeddings",
|
|
21
|
+
"tree-sitter",
|
|
22
|
+
"ai"
|
|
23
|
+
],
|
|
24
|
+
"author": "",
|
|
25
|
+
"license": "GPL-3.0-only",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/Aetherall/lmgrep.git"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"completions",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"packageManager": "pnpm@10.28.0",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@lancedb/lancedb": "^0.27.2",
|
|
38
|
+
"@lumis-sh/wasm-bash": "^0.26.1",
|
|
39
|
+
"@lumis-sh/wasm-c": "^0.26.1",
|
|
40
|
+
"@lumis-sh/wasm-cpp": "^0.26.0",
|
|
41
|
+
"@lumis-sh/wasm-csharp": "^0.26.1",
|
|
42
|
+
"@lumis-sh/wasm-css": "^0.26.2",
|
|
43
|
+
"@lumis-sh/wasm-go": "^0.26.1",
|
|
44
|
+
"@lumis-sh/wasm-html": "^0.26.1",
|
|
45
|
+
"@lumis-sh/wasm-java": "^0.26.1",
|
|
46
|
+
"@lumis-sh/wasm-javascript": "^0.26.2",
|
|
47
|
+
"@lumis-sh/wasm-json": "^0.26.2",
|
|
48
|
+
"@lumis-sh/wasm-kotlin": "^0.26.3",
|
|
49
|
+
"@lumis-sh/wasm-lua": "^0.26.1",
|
|
50
|
+
"@lumis-sh/wasm-markdown": "^0.26.1",
|
|
51
|
+
"@lumis-sh/wasm-nix": "^0.26.0",
|
|
52
|
+
"@lumis-sh/wasm-php": "^0.26.2",
|
|
53
|
+
"@lumis-sh/wasm-python": "^0.26.1",
|
|
54
|
+
"@lumis-sh/wasm-ruby": "^0.26.1",
|
|
55
|
+
"@lumis-sh/wasm-rust": "^0.26.3",
|
|
56
|
+
"@lumis-sh/wasm-scala": "^0.26.1",
|
|
57
|
+
"@lumis-sh/wasm-swift": "^0.26.1",
|
|
58
|
+
"@lumis-sh/wasm-toml": "^0.26.0",
|
|
59
|
+
"@lumis-sh/wasm-tsx": "^0.26.1",
|
|
60
|
+
"@lumis-sh/wasm-typescript": "^0.26.1",
|
|
61
|
+
"@lumis-sh/wasm-vue": "^0.26.0",
|
|
62
|
+
"@lumis-sh/wasm-yaml": "^0.26.0",
|
|
63
|
+
"@lumis-sh/wasm-zig": "^0.26.0",
|
|
64
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
65
|
+
"ai": "^6.0.149",
|
|
66
|
+
"apache-arrow": "^21.1.0",
|
|
67
|
+
"cli-progress": "^3.12.0",
|
|
68
|
+
"commander": "^14.0.3",
|
|
69
|
+
"glob": "^13.0.6",
|
|
70
|
+
"ignore": "^7.0.5",
|
|
71
|
+
"stemmer": "^2.0.1",
|
|
72
|
+
"web-tree-sitter": "^0.26.9",
|
|
73
|
+
"yaml": "^2.8.3",
|
|
74
|
+
"zod": "^4.3.6"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@ai-sdk/openai": "^3.0.51",
|
|
78
|
+
"@biomejs/biome": "^2.4.10",
|
|
79
|
+
"@types/cli-progress": "^3.11.6",
|
|
80
|
+
"@types/node": "^25.5.2",
|
|
81
|
+
"typescript": "^6.0.2"
|
|
82
|
+
},
|
|
83
|
+
"optionalDependencies": {
|
|
84
|
+
"hyperswarm": "^4.17.0"
|
|
85
|
+
}
|
|
65
86
|
}
|
package/dist/lib/build.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type Embedder } from "./embedder.js";
|
|
2
|
-
import { type Store } from "./store.js";
|
|
3
|
-
import type { Chunker, Logger, LmgrepConfig, BuildOptions } from "./types.js";
|
|
4
|
-
export declare function build(cwd: string, store: Store, config: LmgrepConfig, embedder: Embedder, chunker: Chunker, opts?: BuildOptions, logger?: Logger): Promise<{
|
|
5
|
-
succeeded: number;
|
|
6
|
-
failed: number;
|
|
7
|
-
}>;
|
package/dist/lib/build.js
DELETED
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { execSync } from "node:child_process";
|
|
2
|
-
import { ResilientEmbedder, EmbeddingAbortError, } from "./embedder.js";
|
|
3
|
-
import { walkFiles, detectChanges, filterByMtime } from "./scanner.js";
|
|
4
|
-
import { writeProjectMetadata } from "./store.js";
|
|
5
|
-
import { consoleLogger } from "./types.js";
|
|
6
|
-
function gitCmd(cwd, ...args) {
|
|
7
|
-
try {
|
|
8
|
-
return execSync(`git ${args.join(" ")}`, {
|
|
9
|
-
cwd,
|
|
10
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
11
|
-
timeout: 5000,
|
|
12
|
-
})
|
|
13
|
-
.toString()
|
|
14
|
-
.trim();
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function parseDuration(s) {
|
|
21
|
-
const match = s.match(/^(\d+)\s*(s|m|h|d)$/);
|
|
22
|
-
if (!match)
|
|
23
|
-
throw new Error(`Invalid duration "${s}". Use e.g. 10m, 2h, 1d`);
|
|
24
|
-
const n = Number.parseInt(match[1], 10);
|
|
25
|
-
const unit = match[2];
|
|
26
|
-
const multipliers = {
|
|
27
|
-
s: 1000,
|
|
28
|
-
m: 60_000,
|
|
29
|
-
h: 3_600_000,
|
|
30
|
-
d: 86_400_000,
|
|
31
|
-
};
|
|
32
|
-
return n * multipliers[unit];
|
|
33
|
-
}
|
|
34
|
-
export async function build(cwd, store, config, embedder, chunker, opts = {}, logger = consoleLogger) {
|
|
35
|
-
const log = logger.info.bind(logger);
|
|
36
|
-
const emit = opts.onProgress;
|
|
37
|
-
if (opts.reset) {
|
|
38
|
-
log("Resetting index...");
|
|
39
|
-
await store.reset();
|
|
40
|
-
}
|
|
41
|
-
// 0. Bootstrap new branch manifest from merge base
|
|
42
|
-
if (!opts.reset) {
|
|
43
|
-
const existingHashes = await store.getFileHashes();
|
|
44
|
-
if (existingHashes.size === 0) {
|
|
45
|
-
const storedBranches = await store.getStoredBranches();
|
|
46
|
-
if (storedBranches.length > 0) {
|
|
47
|
-
// Find the best source branch via merge-base
|
|
48
|
-
let bestBranch;
|
|
49
|
-
let bestScore = -1;
|
|
50
|
-
for (const candidate of storedBranches) {
|
|
51
|
-
const mergeBase = gitCmd(cwd, "merge-base", "HEAD", candidate);
|
|
52
|
-
if (!mergeBase)
|
|
53
|
-
continue;
|
|
54
|
-
// Count commits between merge-base and HEAD — fewer = closer
|
|
55
|
-
const ahead = gitCmd(cwd, "rev-list", "--count", `${mergeBase}..HEAD`);
|
|
56
|
-
const distance = ahead ? Number.parseInt(ahead, 10) : Infinity;
|
|
57
|
-
if (distance < Infinity && (bestBranch === undefined || distance < bestScore)) {
|
|
58
|
-
bestBranch = candidate;
|
|
59
|
-
bestScore = distance;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (bestBranch) {
|
|
63
|
-
const copied = await store.copyBranchManifest(bestBranch);
|
|
64
|
-
if (copied > 0) {
|
|
65
|
-
log(`Bootstrapped from "${bestBranch}" manifest (${copied} files). Diffing changes...`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// 1. Scan
|
|
72
|
-
let files;
|
|
73
|
-
if (opts.files && opts.files.length > 0) {
|
|
74
|
-
files = opts.files;
|
|
75
|
-
log(`Processing ${files.length} targeted files`);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
files = walkFiles(cwd, config.ignore, config.extensions);
|
|
79
|
-
if (opts.since) {
|
|
80
|
-
const cutoff = Date.now() - parseDuration(opts.since);
|
|
81
|
-
const before = files.length;
|
|
82
|
-
files = filterByMtime(files, cwd, cutoff);
|
|
83
|
-
log(`Found ${files.length} files modified in the last ${opts.since} (out of ${before})`);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
log(`Found ${files.length} files`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
emit?.({ phase: "scan", current: files.length, total: files.length });
|
|
90
|
-
// 2. Change detection
|
|
91
|
-
const storedHashes = await store.getFileHashes();
|
|
92
|
-
const { changed, currentHashes } = detectChanges(files, storedHashes, cwd, opts.force);
|
|
93
|
-
log(`${changed.length} files changed out of ${files.length}`);
|
|
94
|
-
if (changed.length === 0) {
|
|
95
|
-
log("No changes detected. Index is up to date.");
|
|
96
|
-
return { succeeded: 0, failed: 0 };
|
|
97
|
-
}
|
|
98
|
-
// 2b. Skip files whose content hash is already known (indexed on another branch)
|
|
99
|
-
const knownHashes = await store.filterKnownFileHashes(changed.map((f) => f.hash));
|
|
100
|
-
const alreadyKnown = [];
|
|
101
|
-
const trulyChanged = [];
|
|
102
|
-
for (const f of changed) {
|
|
103
|
-
if (knownHashes.has(f.hash)) {
|
|
104
|
-
alreadyKnown.push(f);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
trulyChanged.push(f);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (alreadyKnown.length > 0) {
|
|
111
|
-
// Register these files on the current branch without re-chunking
|
|
112
|
-
const hashEntries = alreadyKnown.map((f) => ({
|
|
113
|
-
filePath: f.path,
|
|
114
|
-
fileHash: f.hash,
|
|
115
|
-
}));
|
|
116
|
-
await store.upsertFileHashes(hashEntries);
|
|
117
|
-
log(`${alreadyKnown.length} files already indexed (content known from other branches)`);
|
|
118
|
-
}
|
|
119
|
-
if (trulyChanged.length === 0) {
|
|
120
|
-
log("No new content to index.");
|
|
121
|
-
return { succeeded: 0, failed: 0 };
|
|
122
|
-
}
|
|
123
|
-
// 3. Chunk changed files
|
|
124
|
-
const changedPaths = trulyChanged.map((f) => f.path);
|
|
125
|
-
const allChunks = [];
|
|
126
|
-
for (let i = 0; i < changedPaths.length; i++) {
|
|
127
|
-
try {
|
|
128
|
-
const chunks = await chunker.chunk(changedPaths[i], cwd);
|
|
129
|
-
allChunks.push(...chunks);
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
// skip files that fail to parse
|
|
133
|
-
}
|
|
134
|
-
if ((i + 1) % 1000 === 0 || i === changedPaths.length - 1) {
|
|
135
|
-
emit?.({
|
|
136
|
-
phase: "chunk",
|
|
137
|
-
current: i + 1,
|
|
138
|
-
total: changedPaths.length,
|
|
139
|
-
message: `${allChunks.length} chunks`,
|
|
140
|
-
});
|
|
141
|
-
log(`Chunking: ${i + 1}/${changedPaths.length} files, ${allChunks.length} chunks so far`);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (allChunks.length === 0) {
|
|
145
|
-
log("No chunks produced. Index is up to date.");
|
|
146
|
-
return { succeeded: 0, failed: 0 };
|
|
147
|
-
}
|
|
148
|
-
if (opts.dry) {
|
|
149
|
-
for (const f of changedPaths)
|
|
150
|
-
log(` ${f}`);
|
|
151
|
-
return { succeeded: 0, failed: 0 };
|
|
152
|
-
}
|
|
153
|
-
// 4. Delete old chunks for changed files
|
|
154
|
-
await store.deleteChunksByFiles(changedPaths);
|
|
155
|
-
// 5. Filter out already-indexed chunks (by hash, queried in DB)
|
|
156
|
-
const existingHashes = await store.filterExistingChunkHashes(allChunks.map((c) => c.hash));
|
|
157
|
-
let newChunks = allChunks.filter((c) => !existingHashes.has(c.hash));
|
|
158
|
-
const alreadyIndexed = allChunks.length - newChunks.length;
|
|
159
|
-
// Filter oversized chunks
|
|
160
|
-
let skippedOversize = 0;
|
|
161
|
-
if (config.maxTokens) {
|
|
162
|
-
const before = newChunks.length;
|
|
163
|
-
newChunks = newChunks.filter((c) => {
|
|
164
|
-
const est = Math.ceil((c.context.length + c.content.length) / 4);
|
|
165
|
-
return est <= config.maxTokens;
|
|
166
|
-
});
|
|
167
|
-
skippedOversize = before - newChunks.length;
|
|
168
|
-
}
|
|
169
|
-
log(`${changedPaths.length} files changed, ${allChunks.length} chunks total, ${newChunks.length} to embed` +
|
|
170
|
-
` (${alreadyIndexed} already indexed${skippedOversize > 0 ? `, ${skippedOversize} oversized` : ""})`);
|
|
171
|
-
if (newChunks.length === 0) {
|
|
172
|
-
const hashEntries = changedPaths
|
|
173
|
-
.filter((fp) => currentHashes.has(fp))
|
|
174
|
-
.map((fp) => ({
|
|
175
|
-
filePath: fp,
|
|
176
|
-
fileHash: currentHashes.get(fp),
|
|
177
|
-
}));
|
|
178
|
-
if (hashEntries.length > 0)
|
|
179
|
-
await store.upsertFileHashes(hashEntries);
|
|
180
|
-
log("All chunks already indexed.");
|
|
181
|
-
return { succeeded: 0, failed: 0 };
|
|
182
|
-
}
|
|
183
|
-
// 6. Embed and store
|
|
184
|
-
const resilient = new ResilientEmbedder(embedder, config, {
|
|
185
|
-
onBatchStart(batchNum, total) {
|
|
186
|
-
emit?.({ phase: "embed", current: batchNum, total });
|
|
187
|
-
},
|
|
188
|
-
onBatchDone(batchNum, succeeded, failed) {
|
|
189
|
-
log(`Batch ${batchNum}: ${succeeded} ok / ${failed} err / ${newChunks.length} total`);
|
|
190
|
-
},
|
|
191
|
-
onReload(attempt, max) {
|
|
192
|
-
log(`Consecutive failures — reloading model (attempt ${attempt}/${max})...`);
|
|
193
|
-
},
|
|
194
|
-
});
|
|
195
|
-
const texts = newChunks.map((c) => `${c.context}\n${c.content}`);
|
|
196
|
-
let vectors;
|
|
197
|
-
let failedIndices;
|
|
198
|
-
let aborted = false;
|
|
199
|
-
try {
|
|
200
|
-
const result = await resilient.embedBatched(texts);
|
|
201
|
-
vectors = result.vectors;
|
|
202
|
-
failedIndices = result.failedIndices;
|
|
203
|
-
}
|
|
204
|
-
catch (err) {
|
|
205
|
-
if (err instanceof EmbeddingAbortError) {
|
|
206
|
-
aborted = true;
|
|
207
|
-
vectors = err.vectors;
|
|
208
|
-
failedIndices = err.failedIndices;
|
|
209
|
-
logger.error(err.message);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
throw err;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
// Store successful chunks
|
|
216
|
-
const indexed = [];
|
|
217
|
-
const failedFiles = new Set();
|
|
218
|
-
let embeddingDimensions;
|
|
219
|
-
for (let i = 0; i < newChunks.length; i++) {
|
|
220
|
-
if (vectors[i] !== null) {
|
|
221
|
-
indexed.push({ ...newChunks[i], vector: vectors[i] });
|
|
222
|
-
if (embeddingDimensions === undefined) {
|
|
223
|
-
embeddingDimensions = vectors[i].length;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
failedFiles.add(newChunks[i].filePath);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
if (indexed.length > 0) {
|
|
231
|
-
const STORE_BATCH = 500;
|
|
232
|
-
for (let i = 0; i < indexed.length; i += STORE_BATCH) {
|
|
233
|
-
await store.addChunks(indexed.slice(i, i + STORE_BATCH));
|
|
234
|
-
emit?.({
|
|
235
|
-
phase: "store",
|
|
236
|
-
current: Math.min(i + STORE_BATCH, indexed.length),
|
|
237
|
-
total: indexed.length,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
// Save file hashes for files with no failures
|
|
242
|
-
const hashEntries = changedPaths
|
|
243
|
-
.filter((fp) => currentHashes.has(fp) && !failedFiles.has(fp))
|
|
244
|
-
.map((fp) => ({ filePath: fp, fileHash: currentHashes.get(fp) }));
|
|
245
|
-
if (hashEntries.length > 0)
|
|
246
|
-
await store.upsertFileHashes(hashEntries);
|
|
247
|
-
const succeeded = indexed.length;
|
|
248
|
-
const failed = failedIndices.size;
|
|
249
|
-
if (aborted) {
|
|
250
|
-
if (succeeded > 0) {
|
|
251
|
-
log(`Saved ${succeeded} chunks before aborting.`);
|
|
252
|
-
}
|
|
253
|
-
log(`Embedding failed. ${failed} chunks could not be embedded. ` +
|
|
254
|
-
`Fix your embedding provider and run \`lmgrep index\` to resume.`);
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
log(`Done: ${succeeded} chunks indexed from ${changedPaths.length} files` +
|
|
258
|
-
(failed > 0 ? ` (${failed} failed)` : ""));
|
|
259
|
-
}
|
|
260
|
-
// Update project metadata (preserve original model/dimensions as baseline)
|
|
261
|
-
writeProjectMetadata(cwd, {
|
|
262
|
-
model: config.model,
|
|
263
|
-
dimensions: embeddingDimensions,
|
|
264
|
-
});
|
|
265
|
-
// Sweep stale branch manifests for branches that no longer exist in git
|
|
266
|
-
await sweepStaleBranches(cwd, store, logger);
|
|
267
|
-
return { succeeded, failed };
|
|
268
|
-
}
|
|
269
|
-
async function sweepStaleBranches(cwd, store, logger) {
|
|
270
|
-
const gitBranchOutput = gitCmd(cwd, "branch", "--list", "--format=%(refname:short)");
|
|
271
|
-
if (!gitBranchOutput)
|
|
272
|
-
return;
|
|
273
|
-
const gitBranches = new Set(gitBranchOutput.split("\n").filter(Boolean));
|
|
274
|
-
// Always keep _default (non-git projects)
|
|
275
|
-
gitBranches.add("_default");
|
|
276
|
-
const storedBranches = await store.getStoredBranches();
|
|
277
|
-
for (const branch of storedBranches) {
|
|
278
|
-
if (!gitBranches.has(branch)) {
|
|
279
|
-
await store.deleteBranchManifest(branch);
|
|
280
|
-
logger.info(`Swept stale manifest for deleted branch "${branch}"`);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
//# sourceMappingURL=build.js.map
|
package/dist/lib/build.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/lib/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAEN,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAc,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAS9D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,SAAS,MAAM,CAAC,GAAW,EAAE,GAAG,IAAc;IAC7C,IAAI,CAAC;QACJ,OAAO,QAAQ,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;YACxC,GAAG;YACH,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;YACnC,OAAO,EAAE,IAAI;SACb,CAAC;aACA,QAAQ,EAAE;aACV,IAAI,EAAE,CAAC;IACV,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC;AAED,SAAS,aAAa,CAAC,CAAS;IAC/B,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC7C,IAAI,CAAC,KAAK;QACT,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,yBAAyB,CAAC,CAAC;IAClE,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,WAAW,GAA2B;QAC3C,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,MAAM;QACT,CAAC,EAAE,SA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Q,EAAE,QAAQ,EAAE,2BAA2B,CAAC,CAAC;IACrF,IAAI,CAAC,eAAe;QAAE,OAAO;IAE7B,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACzE,0CAA0C;IAC1C,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAE5B,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC;IACvD,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE,CAAC;QACrC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,MAAM,KAAK,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,4CAA4C,MAAM,GAAG,CAAC,CAAC;QACpE,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type Parser from "web-tree-sitter";
|
|
2
|
-
import type { LanguageConfig } from "./languages.js";
|
|
3
|
-
export type StructuralRole = "definition" | "orchestration" | "implementation";
|
|
4
|
-
export interface ScopeEntry {
|
|
5
|
-
kind: string;
|
|
6
|
-
name: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ChunkContext {
|
|
9
|
-
filePath: string;
|
|
10
|
-
scope: ScopeEntry[];
|
|
11
|
-
leadingComment: string | null;
|
|
12
|
-
role: StructuralRole;
|
|
13
|
-
}
|
|
14
|
-
/** Walk up from a node to collect typed parent scopes */
|
|
15
|
-
export declare function extractScope(node: Parser.SyntaxNode, langConfig: LanguageConfig): ScopeEntry[];
|
|
16
|
-
/** Extract leading comments and decorators immediately before a node */
|
|
17
|
-
export declare function extractLeadingComment(node: Parser.SyntaxNode, source: string): string | null;
|
|
18
|
-
/** Classify a chunk's structural role based on its AST node type */
|
|
19
|
-
export declare function classifyRole(node: Parser.SyntaxNode): StructuralRole;
|
|
20
|
-
/** Build the context prefix string for a chunk */
|
|
21
|
-
export declare function buildContextString(ctx: ChunkContext): string;
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
const SCOPE_KIND_MAP = {
|
|
2
|
-
// TypeScript / JavaScript
|
|
3
|
-
class_declaration: "class",
|
|
4
|
-
class_body: "class",
|
|
5
|
-
interface_declaration: "interface",
|
|
6
|
-
module: "module",
|
|
7
|
-
namespace_declaration: "namespace",
|
|
8
|
-
// Python
|
|
9
|
-
class_definition: "class",
|
|
10
|
-
// Rust
|
|
11
|
-
impl_item: "impl",
|
|
12
|
-
trait_item: "trait",
|
|
13
|
-
mod_item: "mod",
|
|
14
|
-
// Go
|
|
15
|
-
type_declaration: "type",
|
|
16
|
-
// Ruby
|
|
17
|
-
class: "class",
|
|
18
|
-
// C / C++
|
|
19
|
-
struct_specifier: "struct",
|
|
20
|
-
class_specifier: "class",
|
|
21
|
-
namespace_definition: "namespace",
|
|
22
|
-
// Swift
|
|
23
|
-
struct_declaration: "struct",
|
|
24
|
-
extension_declaration: "extension",
|
|
25
|
-
// Scala
|
|
26
|
-
object_definition: "object",
|
|
27
|
-
trait_definition: "trait",
|
|
28
|
-
// Generic
|
|
29
|
-
ContainerDecl: "container",
|
|
30
|
-
};
|
|
31
|
-
const DEFINITION_TYPES = new Set([
|
|
32
|
-
"class_declaration",
|
|
33
|
-
"class_definition",
|
|
34
|
-
"interface_declaration",
|
|
35
|
-
"type_alias_declaration",
|
|
36
|
-
"enum_declaration",
|
|
37
|
-
"struct_item",
|
|
38
|
-
"enum_item",
|
|
39
|
-
"trait_item",
|
|
40
|
-
"type_item",
|
|
41
|
-
"type_declaration",
|
|
42
|
-
"struct_specifier",
|
|
43
|
-
"class_specifier",
|
|
44
|
-
"enum_specifier",
|
|
45
|
-
"type_definition",
|
|
46
|
-
"struct_declaration",
|
|
47
|
-
"protocol_declaration",
|
|
48
|
-
"trait_definition",
|
|
49
|
-
"ContainerDecl",
|
|
50
|
-
]);
|
|
51
|
-
const ORCHESTRATION_TYPES = new Set([
|
|
52
|
-
"export_statement",
|
|
53
|
-
"decorated_definition",
|
|
54
|
-
]);
|
|
55
|
-
/** Walk up from a node to collect typed parent scopes */
|
|
56
|
-
export function extractScope(node, langConfig) {
|
|
57
|
-
const scopes = [];
|
|
58
|
-
let current = node.parent;
|
|
59
|
-
while (current) {
|
|
60
|
-
if (langConfig.scopeTypes.includes(current.type)) {
|
|
61
|
-
const name = extractNodeName(current);
|
|
62
|
-
if (name) {
|
|
63
|
-
const kind = SCOPE_KIND_MAP[current.type] ?? current.type;
|
|
64
|
-
scopes.unshift({ kind, name });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
current = current.parent;
|
|
68
|
-
}
|
|
69
|
-
return scopes;
|
|
70
|
-
}
|
|
71
|
-
/** Extract leading comments and decorators immediately before a node */
|
|
72
|
-
export function extractLeadingComment(node, source) {
|
|
73
|
-
const lines = source.split("\n");
|
|
74
|
-
const nodeStartLine = node.startPosition.row;
|
|
75
|
-
const collected = [];
|
|
76
|
-
for (let i = nodeStartLine - 1; i >= 0 && i >= nodeStartLine - 10; i--) {
|
|
77
|
-
const line = lines[i].trim();
|
|
78
|
-
if (line.startsWith("//") ||
|
|
79
|
-
line.startsWith("#") ||
|
|
80
|
-
line.startsWith("*") ||
|
|
81
|
-
line.startsWith("/*") ||
|
|
82
|
-
line.startsWith("*/") ||
|
|
83
|
-
line.startsWith("///") ||
|
|
84
|
-
line.startsWith("--") ||
|
|
85
|
-
line.startsWith("@") ||
|
|
86
|
-
line.startsWith('"""') ||
|
|
87
|
-
line.startsWith("'''")) {
|
|
88
|
-
collected.unshift(lines[i]);
|
|
89
|
-
}
|
|
90
|
-
else if (line === "") {
|
|
91
|
-
if (collected.length > 0)
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (collected.length === 0)
|
|
99
|
-
return null;
|
|
100
|
-
return collected.join("\n").trim();
|
|
101
|
-
}
|
|
102
|
-
/** Classify a chunk's structural role based on its AST node type */
|
|
103
|
-
export function classifyRole(node) {
|
|
104
|
-
if (DEFINITION_TYPES.has(node.type))
|
|
105
|
-
return "definition";
|
|
106
|
-
if (ORCHESTRATION_TYPES.has(node.type))
|
|
107
|
-
return "orchestration";
|
|
108
|
-
return "implementation";
|
|
109
|
-
}
|
|
110
|
-
/** Build the context prefix string for a chunk */
|
|
111
|
-
export function buildContextString(ctx) {
|
|
112
|
-
const lines = [];
|
|
113
|
-
lines.push(`[file: ${ctx.filePath}]`);
|
|
114
|
-
lines.push(`[role: ${ctx.role}]`);
|
|
115
|
-
if (ctx.scope.length > 0) {
|
|
116
|
-
const scopeStr = ctx.scope
|
|
117
|
-
.map((s) => `${s.kind} ${s.name}`)
|
|
118
|
-
.join(" > ");
|
|
119
|
-
lines.push(`[scope: ${scopeStr}]`);
|
|
120
|
-
}
|
|
121
|
-
if (ctx.leadingComment) {
|
|
122
|
-
lines.push(`[doc: ${ctx.leadingComment}]`);
|
|
123
|
-
}
|
|
124
|
-
return lines.join("\n");
|
|
125
|
-
}
|
|
126
|
-
function extractNodeName(node) {
|
|
127
|
-
const nameNode = node.childForFieldName("name") ??
|
|
128
|
-
node.children.find((c) => c.type === "identifier" || c.type === "type_identifier");
|
|
129
|
-
return nameNode?.text;
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/lib/chunker/context.ts"],"names":[],"mappings":"AAiBA,MAAM,cAAc,GAA2B;IAC9C,0BAA0B;IAC1B,iBAAiB,EAAE,OAAO;IAC1B,UAAU,EAAE,OAAO;IACnB,qBAAqB,EAAE,WAAW;IAClC,MAAM,EAAE,QAAQ;IAChB,qBAAqB,EAAE,WAAW;IAClC,SAAS;IACT,gBAAgB,EAAE,OAAO;IACzB,OAAO;IAC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AC,CAAC;AACzB,CAAC;AAED,SAAS,eAAe,CAAC,IAAuB;IAC/C,MAAM,QAAQ,GACb,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,CACjB,CAAC,CAAoB,EAAE,EAAE,CACxB,CAAC,CAAC,IAAI,KAAK,YAAY,IAAI,CAAC,CAAC,IAAI,KAAK,iBAAiB,CACxD,CAAC;IACH,OAAO,QAAQ,EAAE,IAAI,CAAC;AACvB,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Chunk, Chunker } from "../types.js";
|
|
2
|
-
/** Chunk a single file into context-enriched chunks */
|
|
3
|
-
export declare function chunkFile(filePath: string, cwd: string): Promise<Chunk[]>;
|
|
4
|
-
/** Default chunker using tree-sitter with sliding-window fallback */
|
|
5
|
-
export declare class TreeSitterChunker implements Chunker {
|
|
6
|
-
chunk(filePath: string, cwd: string): Promise<Chunk[]>;
|
|
7
|
-
}
|