UNPKG

autosnippet

Version:

Extract code patterns into a knowledge base for AI coding assistants

150 lines (149 loc) 8.23 kB
/** * ServiceMap — DI 容器类型安全映射 * * 将服务名(字符串 key)映射到具体类型,实现编译期类型检查。 * 使用方式:`container.get('searchEngine')` → 自动推导为 `SearchEngine` * * @module ServiceMap */ import type DimensionCopy from '#domain/dimension/DimensionCopy.js'; import type { AgentFactory } from '../agent/AgentFactory.js'; import type { ToolRegistry } from '../agent/tools/ToolRegistry.js'; import type { KnowledgeSyncService } from '../cli/KnowledgeSyncService.js'; import type ProjectGraph from '../core/ast/ProjectGraph.js'; import type Constitution from '../core/constitution/Constitution.js'; import type Gateway from '../core/gateway/Gateway.js'; import type { AiProvider } from '../external/ai/AiProvider.js'; import type { AiProviderManager } from '../external/ai/AiProviderManager.js'; import type AuditLogger from '../infrastructure/audit/AuditLogger.js'; import type AuditStore from '../infrastructure/audit/AuditStore.js'; import type { CacheCoordinator } from '../infrastructure/cache/CacheCoordinator.js'; import type DatabaseConnection from '../infrastructure/database/DatabaseConnection.js'; import type { EventBus } from '../infrastructure/event/EventBus.js'; import type Logger from '../infrastructure/logging/Logger.js'; import type { SignalBus } from '../infrastructure/signal/SignalBus.js'; import type { IndexingPipeline } from '../infrastructure/vector/IndexingPipeline.js'; import type { VectorStore } from '../infrastructure/vector/VectorStore.js'; import type { AuditRepositoryImpl } from '../repository/audit/AuditRepository.js'; import type { BootstrapRepositoryImpl } from '../repository/bootstrap/BootstrapRepository.js'; import type { CodeEntityRepositoryImpl } from '../repository/code/CodeEntityRepository.js'; import type { ProposalRepository } from '../repository/evolution/ProposalRepository.js'; import type { GuardViolationRepositoryImpl } from '../repository/guard/GuardViolationRepository.js'; import type { KnowledgeEdgeRepositoryImpl } from '../repository/knowledge/KnowledgeEdgeRepository.js'; import type { KnowledgeRepositoryImpl } from '../repository/knowledge/KnowledgeRepository.impl.js'; import type { MemoryRepositoryImpl } from '../repository/memory/MemoryRepository.js'; import type { RemoteCommandRepository } from '../repository/remote/RemoteCommandRepository.js'; import type { SessionRepositoryImpl } from '../repository/session/SessionRepository.js'; import type { RecipeSourceRefRepositoryImpl } from '../repository/sourceref/RecipeSourceRefRepository.js'; import type { TokenUsageStore } from '../repository/token/TokenUsageStore.js'; import type { BootstrapTaskManager } from '../service/bootstrap/BootstrapTaskManager.js'; import type { CursorDeliveryPipeline } from '../service/delivery/CursorDeliveryPipeline.js'; import type { ComplianceReporter } from '../service/guard/ComplianceReporter.js'; import type { ExclusionManager } from '../service/guard/ExclusionManager.js'; import type { GuardCheckEngine } from '../service/guard/GuardCheckEngine.js'; import type { GuardFeedbackLoop } from '../service/guard/GuardFeedbackLoop.js'; import type GuardService from '../service/guard/GuardService.js'; import type { RuleLearner } from '../service/guard/RuleLearner.js'; import type { ViolationsStore } from '../service/guard/ViolationsStore.js'; import type { CodeEntityGraph } from '../service/knowledge/CodeEntityGraph.js'; import type { ConfidenceRouter } from '../service/knowledge/ConfidenceRouter.js'; import type { KnowledgeFileWriter } from '../service/knowledge/KnowledgeFileWriter.js'; import type { KnowledgeGraphService } from '../service/knowledge/KnowledgeGraphService.js'; import type { KnowledgeService } from '../service/knowledge/KnowledgeService.js'; import type { RecipeExtractor } from '../service/knowledge/RecipeExtractor.js'; import type { ModuleService } from '../service/module/ModuleService.js'; import type { CouplingAnalyzer } from '../service/panorama/CouplingAnalyzer.js'; import type { LayerInferrer } from '../service/panorama/LayerInferrer.js'; import type { PanoramaAggregator } from '../service/panorama/PanoramaAggregator.js'; import type { PanoramaService } from '../service/panorama/PanoramaService.js'; import type { RoleRefiner } from '../service/panorama/RoleRefiner.js'; import type { FeedbackCollector } from '../service/quality/FeedbackCollector.js'; import type { QualityScorer } from '../service/quality/QualityScorer.js'; import type { RecipeCandidateValidator } from '../service/recipe/RecipeCandidateValidator.js'; import type { RecipeParser } from '../service/recipe/RecipeParser.js'; import type { HybridRetriever } from '../service/search/HybridRetriever.js'; import type SearchEngine from '../service/search/SearchEngine.js'; import type { HitRecorder } from '../service/signal/HitRecorder.js'; import type { SkillHooks } from '../service/skills/SkillHooks.js'; import type { PrimeSearchPipeline } from '../service/task/PrimeSearchPipeline.js'; import type { ContextualEnricher } from '../service/vector/ContextualEnricher.js'; import type { VectorService } from '../service/vector/VectorService.js'; import type { LanguageService } from '../shared/LanguageService.js'; /** * 类型安全的服务映射表 * * 将 DI 容器的字符串 key 映射到具体的服务类型。 * `container.get<K extends keyof ServiceMap>(name: K): ServiceMap[K]` */ export interface ServiceMap { database: DatabaseConnection; logger: ReturnType<typeof Logger.getInstance>; auditStore: AuditStore; auditLogger: AuditLogger; gateway: Gateway; eventBus: EventBus; bootstrapTaskManager: BootstrapTaskManager; knowledgeRepository: KnowledgeRepositoryImpl; knowledgeEdgeRepository: KnowledgeEdgeRepositoryImpl; codeEntityRepository: CodeEntityRepositoryImpl; bootstrapRepository: BootstrapRepositoryImpl; guardViolationRepository: GuardViolationRepositoryImpl; auditRepository: AuditRepositoryImpl; memoryRepository: MemoryRepositoryImpl; sessionRepository: SessionRepositoryImpl; proposalRepository: ProposalRepository; remoteCommandRepository: RemoteCommandRepository; recipeSourceRefRepository: RecipeSourceRefRepositoryImpl; knowledgeFileWriter: KnowledgeFileWriter; knowledgeSyncService: KnowledgeSyncService; qualityScorer: QualityScorer; recipeParser: RecipeParser; recipeCandidateValidator: RecipeCandidateValidator; recipeExtractor: RecipeExtractor | null; feedbackCollector: FeedbackCollector; tokenUsageStore: TokenUsageStore; moduleService: ModuleService; cursorDeliveryPipeline: CursorDeliveryPipeline; primeSearchPipeline: PrimeSearchPipeline; confidenceRouter: ConfidenceRouter; knowledgeService: KnowledgeService; knowledgeGraphService: KnowledgeGraphService; codeEntityGraph: CodeEntityGraph; searchEngine: SearchEngine; vectorStore: VectorStore; indexingPipeline: IndexingPipeline; hybridRetriever: HybridRetriever; discovererRegistry: unknown; enhancementRegistry: unknown; languageService: typeof LanguageService; dimensionCopy: typeof DimensionCopy; constitution: Constitution | null; aiProvider: AiProvider | null; aiProviderManager: AiProviderManager; projectGraph: ProjectGraph | null; vectorService: VectorService; contextualEnricher: ContextualEnricher | null; guardService: GuardService; guardCheckEngine: GuardCheckEngine; exclusionManager: ExclusionManager; ruleLearner: RuleLearner; violationsStore: ViolationsStore; complianceReporter: ComplianceReporter; guardFeedbackLoop: GuardFeedbackLoop; toolRegistry: ToolRegistry; agentFactory: AgentFactory; skillHooks: SkillHooks; signalBus: SignalBus; hitRecorder: HitRecorder; roleRefiner: RoleRefiner; couplingAnalyzer: CouplingAnalyzer; layerInferrer: LayerInferrer; panoramaAggregator: PanoramaAggregator; panoramaService: PanoramaService; cacheCoordinator: CacheCoordinator; _projectRoot: string; _config: Record<string, unknown>; _lang: string | null; _fileCache: unknown[] | null; _embedProvider: unknown; }