autosnippet 3.3.0 → 3.3.3
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/dashboard/dist/assets/icons-BJ2mUBi8.js +1 -0
- package/dashboard/dist/assets/index-B659K9t5.js +128 -0
- package/dashboard/dist/assets/index-NCm40PMD.css +1 -0
- package/dashboard/dist/index.html +3 -3
- package/dist/bin/cli.d.ts +1 -0
- package/dist/bin/cli.js +284 -142
- package/dist/lib/agent/context/ExplorationTracker.d.ts +2 -0
- package/dist/lib/agent/context/ExplorationTracker.js +21 -3
- package/dist/lib/agent/core/ToolExecutionPipeline.d.ts +3 -1
- package/dist/lib/agent/core/ToolExecutionPipeline.js +8 -1
- package/dist/lib/agent/forge/DynamicComposer.d.ts +58 -0
- package/dist/lib/agent/forge/DynamicComposer.js +99 -0
- package/dist/lib/agent/forge/SandboxRunner.d.ts +60 -0
- package/dist/lib/agent/forge/SandboxRunner.js +251 -0
- package/dist/lib/agent/forge/TemporaryToolRegistry.d.ts +76 -0
- package/dist/lib/agent/forge/TemporaryToolRegistry.js +154 -0
- package/dist/lib/agent/forge/ToolForge.d.ts +92 -0
- package/dist/lib/agent/forge/ToolForge.js +239 -0
- package/dist/lib/agent/forge/ToolRequirementAnalyzer.d.ts +44 -0
- package/dist/lib/agent/forge/ToolRequirementAnalyzer.js +119 -0
- package/dist/lib/agent/tools/ToolRegistry.d.ts +2 -0
- package/dist/lib/agent/tools/ToolRegistry.js +4 -0
- package/dist/lib/agent/tools/composite.js +0 -1
- package/dist/lib/agent/tools/index.d.ts +2 -50
- package/dist/lib/agent/tools/index.js +2 -3
- package/dist/lib/agent/tools/lifecycle.d.ts +1 -58
- package/dist/lib/agent/tools/lifecycle.js +2 -75
- package/dist/lib/cli/KnowledgeSyncService.d.ts +26 -0
- package/dist/lib/cli/KnowledgeSyncService.js +33 -1
- package/dist/lib/cli/deploy/FileManifest.d.ts +0 -21
- package/dist/lib/cli/deploy/FileManifest.js +0 -11
- package/dist/lib/domain/knowledge/KnowledgeEntry.d.ts +10 -0
- package/dist/lib/domain/knowledge/KnowledgeEntry.js +2 -0
- package/dist/lib/domain/knowledge/Lifecycle.d.ts +19 -2
- package/dist/lib/domain/knowledge/Lifecycle.js +32 -6
- package/dist/lib/domain/knowledge/UnifiedValidator.d.ts +1 -5
- package/dist/lib/domain/knowledge/UnifiedValidator.js +7 -44
- package/dist/lib/domain/knowledge/values/Stats.d.ts +29 -0
- package/dist/lib/domain/knowledge/values/Stats.js +41 -0
- package/dist/lib/external/mcp/McpServer.d.ts +19 -38
- package/dist/lib/external/mcp/McpServer.js +145 -117
- package/dist/lib/external/mcp/autoApproveInjector.js +0 -2
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.d.ts +26 -1
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +41 -0
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +49 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.d.ts +3 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +27 -0
- package/dist/lib/external/mcp/handlers/bootstrap/skills.js +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +1 -0
- package/dist/lib/external/mcp/handlers/bootstrap-internal.js +2 -0
- package/dist/lib/external/mcp/handlers/browse.d.ts +1 -0
- package/dist/lib/external/mcp/handlers/browse.js +2 -1
- package/dist/lib/external/mcp/handlers/consolidated.d.ts +117 -6
- package/dist/lib/external/mcp/handlers/consolidated.js +251 -71
- package/dist/lib/external/mcp/handlers/guard.d.ts +150 -0
- package/dist/lib/external/mcp/handlers/guard.js +239 -5
- package/dist/lib/external/mcp/handlers/knowledge.d.ts +0 -29
- package/dist/lib/external/mcp/handlers/knowledge.js +1 -76
- package/dist/lib/external/mcp/handlers/panorama.d.ts +36 -0
- package/dist/lib/external/mcp/handlers/panorama.js +156 -0
- package/dist/lib/external/mcp/handlers/system.d.ts +2 -54
- package/dist/lib/external/mcp/handlers/system.js +3 -113
- package/dist/lib/external/mcp/handlers/task.d.ts +13 -24
- package/dist/lib/external/mcp/handlers/task.js +218 -557
- package/dist/lib/external/mcp/handlers/types.d.ts +91 -8
- package/dist/lib/external/mcp/handlers/types.js +18 -1
- package/dist/lib/external/mcp/handlers/wiki-external.d.ts +18 -1
- package/dist/lib/external/mcp/handlers/wiki-external.js +16 -1
- package/dist/lib/external/mcp/tools.d.ts +18 -24
- package/dist/lib/external/mcp/tools.js +132 -159
- package/dist/lib/http/HttpServer.js +52 -0
- package/dist/lib/http/middleware/validate.js +7 -3
- package/dist/lib/http/routes/audit.d.ts +8 -0
- package/dist/lib/http/routes/audit.js +51 -0
- package/dist/lib/http/routes/guardReport.d.ts +10 -0
- package/dist/lib/http/routes/guardReport.js +143 -0
- package/dist/lib/http/routes/knowledge.js +32 -1
- package/dist/lib/http/routes/panorama.d.ts +11 -0
- package/dist/lib/http/routes/panorama.js +322 -0
- package/dist/lib/http/routes/signals.d.ts +10 -0
- package/dist/lib/http/routes/signals.js +104 -0
- package/dist/lib/http/routes/task.d.ts +2 -3
- package/dist/lib/http/routes/task.js +17 -347
- package/dist/lib/http/routes/violations.js +1 -1
- package/dist/lib/infrastructure/audit/AuditLogger.d.ts +6 -1
- package/dist/lib/infrastructure/audit/AuditLogger.js +14 -1
- package/dist/lib/infrastructure/database/drizzle/schema.d.ts +202 -504
- package/dist/lib/infrastructure/database/drizzle/schema.js +38 -69
- package/dist/lib/infrastructure/database/migrations/004_evolution_proposals.d.ts +8 -0
- package/dist/lib/infrastructure/database/migrations/004_evolution_proposals.js +43 -0
- package/dist/lib/infrastructure/database/migrations/005_recipe_source_refs.d.ts +9 -0
- package/dist/lib/infrastructure/database/migrations/005_recipe_source_refs.js +24 -0
- package/dist/lib/infrastructure/logging/Logger.d.ts +2 -0
- package/dist/lib/infrastructure/logging/Logger.js +34 -7
- package/dist/lib/infrastructure/monitoring/ErrorTracker.js +3 -1
- package/dist/lib/infrastructure/monitoring/PerformanceMonitor.d.ts +2 -2
- package/dist/lib/infrastructure/monitoring/PerformanceMonitor.js +12 -10
- package/dist/lib/infrastructure/notification/LarkNotifier.d.ts +24 -0
- package/dist/lib/infrastructure/notification/LarkNotifier.js +97 -0
- package/dist/lib/infrastructure/report/ReportStore.d.ts +45 -0
- package/dist/lib/infrastructure/report/ReportStore.js +133 -0
- package/dist/lib/infrastructure/signal/SignalAggregator.d.ts +18 -0
- package/dist/lib/infrastructure/signal/SignalAggregator.js +84 -0
- package/dist/lib/infrastructure/signal/SignalBridge.d.ts +13 -0
- package/dist/lib/infrastructure/signal/SignalBridge.js +20 -0
- package/dist/lib/infrastructure/signal/SignalBus.d.ts +63 -0
- package/dist/lib/infrastructure/signal/SignalBus.js +106 -0
- package/dist/lib/infrastructure/signal/SignalTraceWriter.d.ts +36 -0
- package/dist/lib/infrastructure/signal/SignalTraceWriter.js +130 -0
- package/dist/lib/infrastructure/vector/HnswVectorAdapter.js +18 -2
- package/dist/lib/injection/ServiceContainer.js +8 -0
- package/dist/lib/injection/ServiceMap.d.ts +16 -10
- package/dist/lib/injection/modules/AgentModule.d.ts +1 -1
- package/dist/lib/injection/modules/AgentModule.js +7 -1
- package/dist/lib/injection/modules/AppModule.d.ts +1 -1
- package/dist/lib/injection/modules/AppModule.js +4 -13
- package/dist/lib/injection/modules/GuardModule.js +27 -2
- package/dist/lib/injection/modules/InfraModule.d.ts +0 -1
- package/dist/lib/injection/modules/InfraModule.js +9 -7
- package/dist/lib/injection/modules/KnowledgeModule.d.ts +5 -0
- package/dist/lib/injection/modules/KnowledgeModule.js +131 -0
- package/dist/lib/injection/modules/PanoramaModule.d.ts +18 -0
- package/dist/lib/injection/modules/PanoramaModule.js +76 -0
- package/dist/lib/injection/modules/SignalModule.d.ts +10 -0
- package/dist/lib/injection/modules/SignalModule.js +84 -0
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.d.ts +1 -0
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.js +6 -0
- package/dist/lib/service/bootstrap/BootstrapTaskManager.d.ts +3 -1
- package/dist/lib/service/bootstrap/BootstrapTaskManager.js +20 -1
- package/dist/lib/service/bootstrap/UiStartupTasks.d.ts +45 -0
- package/dist/lib/service/bootstrap/UiStartupTasks.js +101 -0
- package/dist/lib/service/delivery/AgentInstructionsGenerator.js +4 -5
- package/dist/lib/service/delivery/CursorDeliveryPipeline.d.ts +3 -1
- package/dist/lib/service/delivery/CursorDeliveryPipeline.js +13 -10
- package/dist/lib/service/delivery/RulesGenerator.js +3 -2
- package/dist/lib/service/evolution/ConsolidationAdvisor.d.ts +114 -0
- package/dist/lib/service/evolution/ConsolidationAdvisor.js +542 -0
- package/dist/lib/service/evolution/ContradictionDetector.d.ts +54 -0
- package/dist/lib/service/evolution/ContradictionDetector.js +253 -0
- package/dist/lib/service/evolution/DecayDetector.d.ts +71 -0
- package/dist/lib/service/evolution/DecayDetector.js +244 -0
- package/dist/lib/service/evolution/EnhancementSuggester.d.ts +38 -0
- package/dist/lib/service/evolution/EnhancementSuggester.js +220 -0
- package/dist/lib/service/evolution/KnowledgeMetabolism.d.ts +82 -0
- package/dist/lib/service/evolution/KnowledgeMetabolism.js +167 -0
- package/dist/lib/service/evolution/RedundancyAnalyzer.d.ts +53 -0
- package/dist/lib/service/evolution/RedundancyAnalyzer.js +210 -0
- package/dist/lib/service/evolution/StagingManager.d.ts +57 -0
- package/dist/lib/service/evolution/StagingManager.js +201 -0
- package/dist/lib/service/guard/ComplianceReporter.d.ts +42 -2
- package/dist/lib/service/guard/ComplianceReporter.js +43 -5
- package/dist/lib/service/guard/CoverageAnalyzer.d.ts +54 -0
- package/dist/lib/service/guard/CoverageAnalyzer.js +149 -0
- package/dist/lib/service/guard/GuardCheckEngine.d.ts +42 -0
- package/dist/lib/service/guard/GuardCheckEngine.js +465 -14
- package/dist/lib/service/guard/GuardFeedbackLoop.d.ts +3 -0
- package/dist/lib/service/guard/GuardFeedbackLoop.js +9 -0
- package/dist/lib/service/guard/ReverseGuard.d.ts +73 -0
- package/dist/lib/service/guard/ReverseGuard.js +256 -0
- package/dist/lib/service/guard/RuleLearner.d.ts +12 -0
- package/dist/lib/service/guard/RuleLearner.js +38 -0
- package/dist/lib/service/guard/UncertaintyCollector.d.ts +83 -0
- package/dist/lib/service/guard/UncertaintyCollector.js +149 -0
- package/dist/lib/service/guard/ViolationsStore.d.ts +1 -0
- package/dist/lib/service/guard/ViolationsStore.js +33 -3
- package/dist/lib/service/knowledge/ConfidenceRouter.d.ts +13 -0
- package/dist/lib/service/knowledge/ConfidenceRouter.js +14 -0
- package/dist/lib/service/knowledge/KnowledgeService.js +22 -4
- package/dist/lib/service/knowledge/SourceRefReconciler.d.ts +68 -0
- package/dist/lib/service/knowledge/SourceRefReconciler.js +309 -0
- package/dist/lib/service/panorama/CouplingAnalyzer.d.ts +27 -0
- package/dist/lib/service/panorama/CouplingAnalyzer.js +192 -0
- package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +28 -0
- package/dist/lib/service/panorama/DimensionAnalyzer.js +320 -0
- package/dist/lib/service/panorama/LayerInferrer.d.ts +19 -0
- package/dist/lib/service/panorama/LayerInferrer.js +182 -0
- package/dist/lib/service/panorama/ModuleDiscoverer.d.ts +24 -0
- package/dist/lib/service/panorama/ModuleDiscoverer.js +185 -0
- package/dist/lib/service/panorama/PanoramaAggregator.d.ts +29 -0
- package/dist/lib/service/panorama/PanoramaAggregator.js +228 -0
- package/dist/lib/service/panorama/PanoramaScanner.d.ts +52 -0
- package/dist/lib/service/panorama/PanoramaScanner.js +188 -0
- package/dist/lib/service/panorama/PanoramaService.d.ts +125 -0
- package/dist/lib/service/panorama/PanoramaService.js +363 -0
- package/dist/lib/service/panorama/PanoramaTypes.d.ts +134 -0
- package/dist/lib/service/panorama/PanoramaTypes.js +6 -0
- package/dist/lib/service/panorama/RoleRefiner.d.ts +48 -0
- package/dist/lib/service/panorama/RoleRefiner.js +535 -0
- package/dist/lib/service/search/BM25Scorer.d.ts +2 -2
- package/dist/lib/service/search/CoarseRanker.d.ts +7 -6
- package/dist/lib/service/search/CoarseRanker.js +11 -10
- package/dist/lib/service/search/FieldWeightedScorer.d.ts +81 -0
- package/dist/lib/service/search/FieldWeightedScorer.js +318 -0
- package/dist/lib/service/search/MultiSignalRanker.d.ts +3 -2
- package/dist/lib/service/search/MultiSignalRanker.js +17 -1
- package/dist/lib/service/search/SearchEngine.d.ts +9 -7
- package/dist/lib/service/search/SearchEngine.js +67 -10
- package/dist/lib/service/search/SearchTypes.d.ts +25 -3
- package/dist/lib/service/search/SearchTypes.js +6 -1
- package/dist/lib/service/signal/HitRecorder.d.ts +68 -0
- package/dist/lib/service/signal/HitRecorder.js +173 -0
- package/dist/lib/service/skills/SignalCollector.d.ts +3 -1
- package/dist/lib/service/skills/SignalCollector.js +31 -1
- package/dist/lib/service/task/IntentExtractor.d.ts +66 -0
- package/dist/lib/service/task/IntentExtractor.js +256 -0
- package/dist/lib/service/task/PrimeSearchPipeline.d.ts +54 -0
- package/dist/lib/service/task/PrimeSearchPipeline.js +113 -0
- package/dist/lib/service/vector/VectorService.d.ts +3 -0
- package/dist/lib/service/vector/VectorService.js +38 -4
- package/dist/lib/shared/schemas/mcp-tools.d.ts +41 -96
- package/dist/lib/shared/schemas/mcp-tools.js +59 -119
- package/dist/scripts/analyze-signals.d.ts +20 -0
- package/dist/scripts/analyze-signals.js +155 -0
- package/dist/scripts/diagnose-mcp.js +1 -1
- package/package.json +1 -1
- package/skills/autosnippet-create/SKILL.md +98 -89
- package/skills/autosnippet-devdocs/SKILL.md +55 -57
- package/templates/claude-code/hooks/autosnippet-session.sh +10 -15
- package/templates/cursor-hooks/hooks/session-start.sh +1 -1
- package/templates/guard-ci.yml +2 -2
- package/templates/instructions/agent-static.md +2 -1
- package/templates/instructions/conventions.md +5 -6
- package/templates/recipes-setup/README.md +1 -2
- package/templates/recipes-setup/_template.md +39 -39
- package/dashboard/dist/assets/icons-BofcEZ3f.js +0 -1
- package/dashboard/dist/assets/index-D0whuycy.css +0 -1
- package/dashboard/dist/assets/index-SiN1GChm.js +0 -128
- package/dist/lib/domain/task/Task.d.ts +0 -140
- package/dist/lib/domain/task/Task.js +0 -254
- package/dist/lib/domain/task/TaskDependency.d.ts +0 -23
- package/dist/lib/domain/task/TaskDependency.js +0 -34
- package/dist/lib/domain/task/TaskIdGenerator.d.ts +0 -40
- package/dist/lib/domain/task/TaskIdGenerator.js +0 -75
- package/dist/lib/domain/task/index.d.ts +0 -4
- package/dist/lib/domain/task/index.js +0 -4
- package/dist/lib/infrastructure/database/migrations/002_add_tasks.d.ts +0 -11
- package/dist/lib/infrastructure/database/migrations/002_add_tasks.js +0 -86
- package/dist/lib/repository/task/TaskRepository.impl.d.ts +0 -171
- package/dist/lib/repository/task/TaskRepository.impl.js +0 -347
- package/dist/lib/service/task/TaskGraphService.d.ts +0 -222
- package/dist/lib/service/task/TaskGraphService.js +0 -597
- package/dist/lib/service/task/TaskKnowledgeBridge.d.ts +0 -95
- package/dist/lib/service/task/TaskKnowledgeBridge.js +0 -298
- package/dist/lib/service/task/TaskReadyEngine.d.ts +0 -84
- package/dist/lib/service/task/TaskReadyEngine.js +0 -115
|
@@ -12,17 +12,16 @@ import type { KnowledgeSyncService } from '../cli/KnowledgeSyncService.js';
|
|
|
12
12
|
import type ProjectGraph from '../core/ast/ProjectGraph.js';
|
|
13
13
|
import type Constitution from '../core/constitution/Constitution.js';
|
|
14
14
|
import type Gateway from '../core/gateway/Gateway.js';
|
|
15
|
-
import type { TaskIdGenerator } from '../domain/task/TaskIdGenerator.js';
|
|
16
15
|
import type { AiProvider } from '../external/ai/AiProvider.js';
|
|
17
16
|
import type AuditLogger from '../infrastructure/audit/AuditLogger.js';
|
|
18
17
|
import type AuditStore from '../infrastructure/audit/AuditStore.js';
|
|
19
18
|
import type DatabaseConnection from '../infrastructure/database/DatabaseConnection.js';
|
|
20
19
|
import type { EventBus } from '../infrastructure/event/EventBus.js';
|
|
21
20
|
import type Logger from '../infrastructure/logging/Logger.js';
|
|
21
|
+
import type { SignalBus } from '../infrastructure/signal/SignalBus.js';
|
|
22
22
|
import type { IndexingPipeline } from '../infrastructure/vector/IndexingPipeline.js';
|
|
23
23
|
import type { VectorStore } from '../infrastructure/vector/VectorStore.js';
|
|
24
24
|
import type { KnowledgeRepositoryImpl } from '../repository/knowledge/KnowledgeRepository.impl.js';
|
|
25
|
-
import type { TaskRepositoryImpl } from '../repository/task/TaskRepository.impl.js';
|
|
26
25
|
import type { TokenUsageStore } from '../repository/token/TokenUsageStore.js';
|
|
27
26
|
import type { BootstrapTaskManager } from '../service/bootstrap/BootstrapTaskManager.js';
|
|
28
27
|
import type DimensionCopy from '../service/bootstrap/DimensionCopyRegistry.js';
|
|
@@ -41,16 +40,20 @@ import type { KnowledgeGraphService } from '../service/knowledge/KnowledgeGraphS
|
|
|
41
40
|
import type { KnowledgeService } from '../service/knowledge/KnowledgeService.js';
|
|
42
41
|
import type { RecipeExtractor } from '../service/knowledge/RecipeExtractor.js';
|
|
43
42
|
import type { ModuleService } from '../service/module/ModuleService.js';
|
|
43
|
+
import type { CouplingAnalyzer } from '../service/panorama/CouplingAnalyzer.js';
|
|
44
|
+
import type { LayerInferrer } from '../service/panorama/LayerInferrer.js';
|
|
45
|
+
import type { PanoramaAggregator } from '../service/panorama/PanoramaAggregator.js';
|
|
46
|
+
import type { PanoramaService } from '../service/panorama/PanoramaService.js';
|
|
47
|
+
import type { RoleRefiner } from '../service/panorama/RoleRefiner.js';
|
|
44
48
|
import type { FeedbackCollector } from '../service/quality/FeedbackCollector.js';
|
|
45
49
|
import type { QualityScorer } from '../service/quality/QualityScorer.js';
|
|
46
50
|
import type { RecipeCandidateValidator } from '../service/recipe/RecipeCandidateValidator.js';
|
|
47
51
|
import type { RecipeParser } from '../service/recipe/RecipeParser.js';
|
|
48
52
|
import type { HybridRetriever } from '../service/search/HybridRetriever.js';
|
|
49
53
|
import type SearchEngine from '../service/search/SearchEngine.js';
|
|
54
|
+
import type { HitRecorder } from '../service/signal/HitRecorder.js';
|
|
50
55
|
import type { SkillHooks } from '../service/skills/SkillHooks.js';
|
|
51
|
-
import type {
|
|
52
|
-
import type { TaskKnowledgeBridge } from '../service/task/TaskKnowledgeBridge.js';
|
|
53
|
-
import type { TaskReadyEngine } from '../service/task/TaskReadyEngine.js';
|
|
56
|
+
import type { PrimeSearchPipeline } from '../service/task/PrimeSearchPipeline.js';
|
|
54
57
|
import type { ContextualEnricher } from '../service/vector/ContextualEnricher.js';
|
|
55
58
|
import type { VectorService } from '../service/vector/VectorService.js';
|
|
56
59
|
import type { LanguageService } from '../shared/LanguageService.js';
|
|
@@ -71,7 +74,6 @@ export interface ServiceMap {
|
|
|
71
74
|
knowledgeRepository: KnowledgeRepositoryImpl;
|
|
72
75
|
knowledgeFileWriter: KnowledgeFileWriter;
|
|
73
76
|
knowledgeSyncService: KnowledgeSyncService;
|
|
74
|
-
taskRepository: TaskRepositoryImpl;
|
|
75
77
|
qualityScorer: QualityScorer;
|
|
76
78
|
recipeParser: RecipeParser;
|
|
77
79
|
recipeCandidateValidator: RecipeCandidateValidator;
|
|
@@ -80,10 +82,7 @@ export interface ServiceMap {
|
|
|
80
82
|
tokenUsageStore: TokenUsageStore;
|
|
81
83
|
moduleService: ModuleService;
|
|
82
84
|
cursorDeliveryPipeline: CursorDeliveryPipeline;
|
|
83
|
-
|
|
84
|
-
taskReadyEngine: TaskReadyEngine;
|
|
85
|
-
taskKnowledgeBridge: TaskKnowledgeBridge;
|
|
86
|
-
taskGraphService: TaskGraphService;
|
|
85
|
+
primeSearchPipeline: PrimeSearchPipeline;
|
|
87
86
|
confidenceRouter: ConfidenceRouter;
|
|
88
87
|
knowledgeService: KnowledgeService;
|
|
89
88
|
knowledgeGraphService: KnowledgeGraphService;
|
|
@@ -111,4 +110,11 @@ export interface ServiceMap {
|
|
|
111
110
|
toolRegistry: ToolRegistry;
|
|
112
111
|
agentFactory: AgentFactory;
|
|
113
112
|
skillHooks: SkillHooks;
|
|
113
|
+
signalBus: SignalBus;
|
|
114
|
+
hitRecorder: HitRecorder;
|
|
115
|
+
roleRefiner: RoleRefiner;
|
|
116
|
+
couplingAnalyzer: CouplingAnalyzer;
|
|
117
|
+
layerInferrer: LayerInferrer;
|
|
118
|
+
panoramaAggregator: PanoramaAggregator;
|
|
119
|
+
panoramaService: PanoramaService;
|
|
114
120
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* AgentModule — Agent 架构服务注册
|
|
3
3
|
*
|
|
4
4
|
* 负责注册:
|
|
5
|
-
* - agentFactory, toolRegistry, skillHooks
|
|
5
|
+
* - agentFactory, toolRegistry, toolForge, skillHooks
|
|
6
6
|
* - feedbackStore, recommendationPipeline, recommendationMetrics
|
|
7
7
|
*/
|
|
8
8
|
import type { ServiceContainer } from '../ServiceContainer.js';
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* AgentModule — Agent 架构服务注册
|
|
3
3
|
*
|
|
4
4
|
* 负责注册:
|
|
5
|
-
* - agentFactory, toolRegistry, skillHooks
|
|
5
|
+
* - agentFactory, toolRegistry, toolForge, skillHooks
|
|
6
6
|
* - feedbackStore, recommendationPipeline, recommendationMetrics
|
|
7
7
|
*/
|
|
8
8
|
import { resolveProjectRoot } from '#shared/resolveProjectRoot.js';
|
|
9
9
|
import { AgentFactory } from '../../agent/AgentFactory.js';
|
|
10
|
+
import { ToolForge } from '../../agent/forge/ToolForge.js';
|
|
10
11
|
import { ALL_TOOLS } from '../../agent/tools/index.js';
|
|
11
12
|
import { ToolRegistry } from '../../agent/tools/ToolRegistry.js';
|
|
12
13
|
import { AIRecallStrategy } from '../../service/skills/AIRecallStrategy.js';
|
|
@@ -21,6 +22,11 @@ export function register(c) {
|
|
|
21
22
|
registry.registerAll(ALL_TOOLS);
|
|
22
23
|
return registry;
|
|
23
24
|
});
|
|
25
|
+
c.singleton('toolForge', (ct) => {
|
|
26
|
+
const registry = ct.get('toolRegistry');
|
|
27
|
+
const signalBus = ct.singletons.signalBus;
|
|
28
|
+
return new ToolForge(registry, { signalBus });
|
|
29
|
+
});
|
|
24
30
|
c.singleton('agentFactory', (ct) => new AgentFactory({
|
|
25
31
|
container: ct,
|
|
26
32
|
toolRegistry: ct.get('toolRegistry'),
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* - recipeParser, recipeCandidateValidator
|
|
6
6
|
* - qualityScorer, feedbackCollector, tokenUsageStore, recipeExtractor
|
|
7
7
|
* - moduleService, cursorDeliveryPipeline
|
|
8
|
-
* -
|
|
8
|
+
* - primeSearchPipeline (for prime multi-query search — no DB dependency)
|
|
9
9
|
*/
|
|
10
10
|
import type { ServiceContainer } from '../ServiceContainer.js';
|
|
11
11
|
export declare function register(c: ServiceContainer): void;
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
* - recipeParser, recipeCandidateValidator
|
|
6
6
|
* - qualityScorer, feedbackCollector, tokenUsageStore, recipeExtractor
|
|
7
7
|
* - moduleService, cursorDeliveryPipeline
|
|
8
|
-
* -
|
|
8
|
+
* - primeSearchPipeline (for prime multi-query search — no DB dependency)
|
|
9
9
|
*/
|
|
10
10
|
import { resolveProjectRoot } from '#shared/resolveProjectRoot.js';
|
|
11
|
-
import { TaskIdGenerator } from '../../domain/task/TaskIdGenerator.js';
|
|
12
11
|
import { TokenUsageStore } from '../../repository/token/TokenUsageStore.js';
|
|
13
12
|
import { CursorDeliveryPipeline } from '../../service/delivery/CursorDeliveryPipeline.js';
|
|
14
13
|
import { RecipeExtractor } from '../../service/knowledge/RecipeExtractor.js';
|
|
@@ -17,9 +16,7 @@ import { FeedbackCollector } from '../../service/quality/FeedbackCollector.js';
|
|
|
17
16
|
import { QualityScorer } from '../../service/quality/QualityScorer.js';
|
|
18
17
|
import { RecipeCandidateValidator } from '../../service/recipe/RecipeCandidateValidator.js';
|
|
19
18
|
import { RecipeParser } from '../../service/recipe/RecipeParser.js';
|
|
20
|
-
import {
|
|
21
|
-
import { TaskKnowledgeBridge } from '../../service/task/TaskKnowledgeBridge.js';
|
|
22
|
-
import { TaskReadyEngine } from '../../service/task/TaskReadyEngine.js';
|
|
19
|
+
import { PrimeSearchPipeline } from '../../service/task/PrimeSearchPipeline.js';
|
|
23
20
|
export function register(c) {
|
|
24
21
|
// ═══ Quality + Recipe ═══
|
|
25
22
|
c.singleton('qualityScorer', () => new QualityScorer());
|
|
@@ -52,14 +49,8 @@ export function register(c) {
|
|
|
52
49
|
database: ct.get('database'),
|
|
53
50
|
logger: ct.logger,
|
|
54
51
|
}));
|
|
55
|
-
// ═══
|
|
56
|
-
c.singleton('
|
|
57
|
-
const db = ct.get('database');
|
|
58
|
-
return new TaskIdGenerator(db.getDb(), db.getDrizzle());
|
|
59
|
-
});
|
|
60
|
-
c.singleton('taskReadyEngine', (ct) => new TaskReadyEngine(ct.get('database').getDb()));
|
|
61
|
-
c.singleton('taskKnowledgeBridge', (ct) => new TaskKnowledgeBridge(ct.get('searchEngine')));
|
|
62
|
-
c.singleton('taskGraphService', (ct) => new TaskGraphService(ct.get('taskRepository'), ct.get('taskReadyEngine'), ct.get('taskKnowledgeBridge'), ct.get('auditLogger'), ct.get('taskIdGenerator')));
|
|
52
|
+
// ═══ PrimeSearchPipeline (for prime multi-query search) ═══
|
|
53
|
+
c.singleton('primeSearchPipeline', (ct) => new PrimeSearchPipeline(ct.get('searchEngine')));
|
|
63
54
|
}
|
|
64
55
|
/** 初始化 RecipeExtractor 实例 (在 initialize 期间调用) */
|
|
65
56
|
export function initRecipeExtractor(c) {
|
|
@@ -10,10 +10,12 @@ import fs from 'node:fs';
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import { resolveProjectRoot } from '#shared/resolveProjectRoot.js';
|
|
12
12
|
import { ComplianceReporter } from '../../service/guard/ComplianceReporter.js';
|
|
13
|
+
import { CoverageAnalyzer } from '../../service/guard/CoverageAnalyzer.js';
|
|
13
14
|
import { ExclusionManager } from '../../service/guard/ExclusionManager.js';
|
|
14
15
|
import { GuardCheckEngine } from '../../service/guard/GuardCheckEngine.js';
|
|
15
16
|
import { GuardFeedbackLoop } from '../../service/guard/GuardFeedbackLoop.js';
|
|
16
17
|
import { GuardService } from '../../service/guard/GuardService.js';
|
|
18
|
+
import { ReverseGuard } from '../../service/guard/ReverseGuard.js';
|
|
17
19
|
import { RuleLearner } from '../../service/guard/RuleLearner.js';
|
|
18
20
|
import { ViolationsStore } from '../../service/guard/ViolationsStore.js';
|
|
19
21
|
export function register(c) {
|
|
@@ -61,7 +63,10 @@ export function register(c) {
|
|
|
61
63
|
const proj = Array.isArray(projectGuard.disabledRules) ? projectGuard.disabledRules : [];
|
|
62
64
|
merged.disabledRules = [...new Set([...base, ...proj])];
|
|
63
65
|
}
|
|
64
|
-
return new GuardCheckEngine(ct.get('database'), {
|
|
66
|
+
return new GuardCheckEngine(ct.get('database'), {
|
|
67
|
+
guardConfig: merged,
|
|
68
|
+
signalBus: ct.singletons.signalBus || undefined,
|
|
69
|
+
});
|
|
65
70
|
});
|
|
66
71
|
c.singleton('exclusionManager', (ct) => {
|
|
67
72
|
const projectRoot = resolveProjectRoot(ct);
|
|
@@ -69,7 +74,9 @@ export function register(c) {
|
|
|
69
74
|
});
|
|
70
75
|
c.singleton('ruleLearner', (ct) => {
|
|
71
76
|
const projectRoot = resolveProjectRoot(ct);
|
|
72
|
-
return new RuleLearner(projectRoot
|
|
77
|
+
return new RuleLearner(projectRoot, {
|
|
78
|
+
signalBus: ct.singletons.signalBus || undefined,
|
|
79
|
+
});
|
|
73
80
|
});
|
|
74
81
|
c.singleton('violationsStore', (ct) => {
|
|
75
82
|
const db = ct.get('database');
|
|
@@ -81,5 +88,23 @@ export function register(c) {
|
|
|
81
88
|
});
|
|
82
89
|
c.singleton('guardFeedbackLoop', (ct) => new GuardFeedbackLoop(ct.get('violationsStore'), ct.get('feedbackCollector'), {
|
|
83
90
|
guardCheckEngine: ct.get('guardCheckEngine'),
|
|
91
|
+
signalBus: ct.singletons.signalBus || undefined,
|
|
84
92
|
}));
|
|
93
|
+
c.singleton('reverseGuard', (ct) => {
|
|
94
|
+
const db = ct.get('database');
|
|
95
|
+
return new ReverseGuard(db.getDb(), {
|
|
96
|
+
signalBus: ct.singletons.signalBus || undefined,
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
c.singleton('coverageAnalyzer', (ct) => {
|
|
100
|
+
const db = ct.get('database');
|
|
101
|
+
let ruleLearner;
|
|
102
|
+
try {
|
|
103
|
+
ruleLearner = { ruleLearner: ct.get('ruleLearner') };
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
/* ruleLearner not yet available */
|
|
107
|
+
}
|
|
108
|
+
return new CoverageAnalyzer(db.getDb(), ruleLearner);
|
|
109
|
+
});
|
|
85
110
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* - database, logger, auditStore, auditLogger
|
|
6
6
|
* - gateway, eventBus, bootstrapTaskManager
|
|
7
7
|
* - knowledgeRepository, knowledgeFileWriter, knowledgeSyncService
|
|
8
|
-
* - taskRepository
|
|
9
8
|
*/
|
|
10
9
|
import type { ServiceContainer } from '../ServiceContainer.js';
|
|
11
10
|
export declare function register(c: ServiceContainer): void;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* - database, logger, auditStore, auditLogger
|
|
6
6
|
* - gateway, eventBus, bootstrapTaskManager
|
|
7
7
|
* - knowledgeRepository, knowledgeFileWriter, knowledgeSyncService
|
|
8
|
-
* - taskRepository
|
|
9
8
|
*/
|
|
9
|
+
import path from 'node:path';
|
|
10
10
|
import { resolveProjectRoot } from '#shared/resolveProjectRoot.js';
|
|
11
11
|
import { KnowledgeSyncService } from '../../cli/KnowledgeSyncService.js';
|
|
12
12
|
import Gateway from '../../core/gateway/Gateway.js';
|
|
@@ -15,8 +15,8 @@ import AuditStore from '../../infrastructure/audit/AuditStore.js';
|
|
|
15
15
|
import { EventBus } from '../../infrastructure/event/EventBus.js';
|
|
16
16
|
import Logger from '../../infrastructure/logging/Logger.js';
|
|
17
17
|
import { getRealtimeService as _getRealtimeService } from '../../infrastructure/realtime/RealtimeService.js';
|
|
18
|
+
import { ReportStore } from '../../infrastructure/report/ReportStore.js';
|
|
18
19
|
import { KnowledgeRepositoryImpl } from '../../repository/knowledge/KnowledgeRepository.impl.js';
|
|
19
|
-
import { TaskRepositoryImpl } from '../../repository/task/TaskRepository.impl.js';
|
|
20
20
|
import { BootstrapTaskManager } from '../../service/bootstrap/BootstrapTaskManager.js';
|
|
21
21
|
import { KnowledgeFileWriter } from '../../service/knowledge/KnowledgeFileWriter.js';
|
|
22
22
|
export function register(c) {
|
|
@@ -33,7 +33,9 @@ export function register(c) {
|
|
|
33
33
|
const drizzle = db.getDrizzle();
|
|
34
34
|
return new AuditStore(db, drizzle);
|
|
35
35
|
});
|
|
36
|
-
c.singleton('auditLogger', (ct) => new AuditLogger(ct.get('auditStore')
|
|
36
|
+
c.singleton('auditLogger', (ct) => new AuditLogger(ct.get('auditStore'), ct.services.eventBus
|
|
37
|
+
? ct.get('eventBus')
|
|
38
|
+
: null));
|
|
37
39
|
c.singleton('gateway', () => new Gateway());
|
|
38
40
|
c.singleton('eventBus', () => new EventBus({ maxListeners: 30 }));
|
|
39
41
|
c.singleton('bootstrapTaskManager', (ct) => {
|
|
@@ -65,9 +67,9 @@ export function register(c) {
|
|
|
65
67
|
const projectRoot = resolveProjectRoot(ct);
|
|
66
68
|
return new KnowledgeSyncService(projectRoot);
|
|
67
69
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
return new
|
|
70
|
+
// ═══ ReportStore ═══
|
|
71
|
+
c.singleton('reportStore', (ct) => {
|
|
72
|
+
const projectRoot = resolveProjectRoot(ct);
|
|
73
|
+
return new ReportStore(path.join(projectRoot, '.autosnippet', 'logs', 'reports'));
|
|
72
74
|
});
|
|
73
75
|
}
|
|
@@ -9,3 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { ServiceContainer } from '../ServiceContainer.js';
|
|
11
11
|
export declare function register(c: ServiceContainer): void;
|
|
12
|
+
/**
|
|
13
|
+
* 初始化知识服务(在容器初始化后调用)
|
|
14
|
+
* 绑定 EventBus → SearchEngine.refreshIndex() + recipe_source_refs 填充
|
|
15
|
+
*/
|
|
16
|
+
export declare function initializeKnowledgeServices(c: ServiceContainer): void;
|
|
@@ -14,6 +14,13 @@ import { HnswVectorAdapter } from '../../infrastructure/vector/HnswVectorAdapter
|
|
|
14
14
|
import { IndexingPipeline } from '../../infrastructure/vector/IndexingPipeline.js';
|
|
15
15
|
import { JsonVectorAdapter } from '../../infrastructure/vector/JsonVectorAdapter.js';
|
|
16
16
|
import { DimensionCopy } from '../../service/bootstrap/DimensionCopyRegistry.js';
|
|
17
|
+
import { ConsolidationAdvisor } from '../../service/evolution/ConsolidationAdvisor.js';
|
|
18
|
+
import { ContradictionDetector } from '../../service/evolution/ContradictionDetector.js';
|
|
19
|
+
import { DecayDetector } from '../../service/evolution/DecayDetector.js';
|
|
20
|
+
import { EnhancementSuggester } from '../../service/evolution/EnhancementSuggester.js';
|
|
21
|
+
import { KnowledgeMetabolism } from '../../service/evolution/KnowledgeMetabolism.js';
|
|
22
|
+
import { RedundancyAnalyzer } from '../../service/evolution/RedundancyAnalyzer.js';
|
|
23
|
+
import { StagingManager } from '../../service/evolution/StagingManager.js';
|
|
17
24
|
import { CodeEntityGraph } from '../../service/knowledge/CodeEntityGraph.js';
|
|
18
25
|
import { ConfidenceRouter } from '../../service/knowledge/ConfidenceRouter.js';
|
|
19
26
|
import { KnowledgeGraphService } from '../../service/knowledge/KnowledgeGraphService.js';
|
|
@@ -50,6 +57,7 @@ export function register(c) {
|
|
|
50
57
|
// is sufficient for knowledge-base scale (hundreds~thousands of entries).
|
|
51
58
|
// Re-enable when document scale grows to 10k+ or external noisy sources are integrated.
|
|
52
59
|
crossEncoderReranker: null,
|
|
60
|
+
signalBus: ct.singletons.signalBus || null,
|
|
53
61
|
});
|
|
54
62
|
}, { aiDependent: true });
|
|
55
63
|
c.singleton('vectorStore', (ct) => {
|
|
@@ -120,4 +128,127 @@ export function register(c) {
|
|
|
120
128
|
c.register('constitution', () => c.singletons.constitution || null);
|
|
121
129
|
c.register('aiProvider', () => c.singletons.aiProvider || null);
|
|
122
130
|
c.register('projectGraph', () => c.singletons.projectGraph || null);
|
|
131
|
+
// ═══ Governance / Evolution ═══
|
|
132
|
+
c.singleton('stagingManager', (ct) => {
|
|
133
|
+
const db = ct.get('database');
|
|
134
|
+
return new StagingManager(db.getDb(), {
|
|
135
|
+
signalBus: ct.singletons.signalBus || undefined,
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
c.singleton('decayDetector', (ct) => {
|
|
139
|
+
const db = ct.get('database');
|
|
140
|
+
return new DecayDetector(db.getDb(), {
|
|
141
|
+
signalBus: ct.singletons.signalBus || undefined,
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
c.singleton('contradictionDetector', (ct) => {
|
|
145
|
+
const db = ct.get('database');
|
|
146
|
+
return new ContradictionDetector(db.getDb(), {
|
|
147
|
+
signalBus: ct.singletons.signalBus || undefined,
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
c.singleton('redundancyAnalyzer', (ct) => {
|
|
151
|
+
const db = ct.get('database');
|
|
152
|
+
return new RedundancyAnalyzer(db.getDb(), {
|
|
153
|
+
signalBus: ct.singletons.signalBus || undefined,
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
c.singleton('enhancementSuggester', (ct) => {
|
|
157
|
+
const db = ct.get('database');
|
|
158
|
+
return new EnhancementSuggester(db.getDb(), {
|
|
159
|
+
signalBus: ct.singletons.signalBus || undefined,
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
c.singleton('knowledgeMetabolism', (ct) => {
|
|
163
|
+
return new KnowledgeMetabolism({
|
|
164
|
+
contradictionDetector: ct.get('contradictionDetector'),
|
|
165
|
+
redundancyAnalyzer: ct.get('redundancyAnalyzer'),
|
|
166
|
+
decayDetector: ct.get('decayDetector'),
|
|
167
|
+
signalBus: ct.singletons.signalBus || undefined,
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
c.singleton('consolidationAdvisor', (ct) => {
|
|
171
|
+
const db = ct.get('database');
|
|
172
|
+
return new ConsolidationAdvisor(db.getDb());
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* 初始化知识服务(在容器初始化后调用)
|
|
177
|
+
* 绑定 EventBus → SearchEngine.refreshIndex() + recipe_source_refs 填充
|
|
178
|
+
*/
|
|
179
|
+
export function initializeKnowledgeServices(c) {
|
|
180
|
+
if (!c.services.eventBus || !c.services.searchEngine) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const { EventBus } = await_import_EventBus();
|
|
185
|
+
const eventBus = c.get('eventBus');
|
|
186
|
+
const searchEngine = c.get('searchEngine');
|
|
187
|
+
// Bug 修复: BM25 索引与 Vector 索引一致性 — 将 knowledge:changed 事件绑定到 refreshIndex
|
|
188
|
+
eventBus.on('knowledge:changed', () => {
|
|
189
|
+
try {
|
|
190
|
+
searchEngine.refreshIndex();
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
/* refreshIndex failure is non-fatal */
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
// recipe_source_refs 填充:MCP 内提交新知识后同步更新桥接表
|
|
197
|
+
eventBus.on('knowledge:changed', (data) => {
|
|
198
|
+
try {
|
|
199
|
+
const d = data;
|
|
200
|
+
if (d.action === 'create' && d.entryId) {
|
|
201
|
+
_populateSourceRefsForEntry(c, d.entryId);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
/* sourceRef population failure is non-fatal */
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
/* EventBus/SearchEngine not available — skip binding */
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/** EventBus 延迟引用(避免循环依赖) */
|
|
214
|
+
function await_import_EventBus() {
|
|
215
|
+
// EventBus 类型已经通过 container 解析,此处只用于 TS 类型
|
|
216
|
+
return {
|
|
217
|
+
EventBus: Object,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 从 knowledge_entries.reasoning 中提取 sources 并填充 recipe_source_refs 桥接表
|
|
222
|
+
*/
|
|
223
|
+
function _populateSourceRefsForEntry(c, entryId) {
|
|
224
|
+
const db = c.get('database');
|
|
225
|
+
const rawDb = db.getDb();
|
|
226
|
+
const row = rawDb.prepare(`SELECT reasoning FROM knowledge_entries WHERE id = ?`).get(entryId);
|
|
227
|
+
if (!row?.reasoning) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
let sources = [];
|
|
231
|
+
try {
|
|
232
|
+
const reasoning = JSON.parse(row.reasoning);
|
|
233
|
+
sources = Array.isArray(reasoning.sources)
|
|
234
|
+
? reasoning.sources.filter((s) => typeof s === 'string' && s.length > 0)
|
|
235
|
+
: [];
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (sources.length === 0) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const now = Date.now();
|
|
244
|
+
const upsert = rawDb.prepare(`INSERT OR REPLACE INTO recipe_source_refs (recipe_id, source_path, status, verified_at)
|
|
245
|
+
VALUES (?, ?, 'active', ?)`);
|
|
246
|
+
for (const sourcePath of sources) {
|
|
247
|
+
try {
|
|
248
|
+
upsert.run(entryId, sourcePath, now);
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
/* table may not exist yet */
|
|
252
|
+
}
|
|
253
|
+
}
|
|
123
254
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PanoramaModule — DI 注册
|
|
3
|
+
*
|
|
4
|
+
* 注册全景服务到 ServiceContainer:
|
|
5
|
+
* - moduleDiscoverer
|
|
6
|
+
* - roleRefiner
|
|
7
|
+
* - couplingAnalyzer
|
|
8
|
+
* - layerInferrer
|
|
9
|
+
* - panoramaAggregator
|
|
10
|
+
* - panoramaScanner
|
|
11
|
+
* - panoramaService
|
|
12
|
+
*
|
|
13
|
+
* @module PanoramaModule
|
|
14
|
+
*/
|
|
15
|
+
import type { ServiceContainer } from '../ServiceContainer.js';
|
|
16
|
+
export declare const PanoramaModule: {
|
|
17
|
+
register(container: ServiceContainer): void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PanoramaModule — DI 注册
|
|
3
|
+
*
|
|
4
|
+
* 注册全景服务到 ServiceContainer:
|
|
5
|
+
* - moduleDiscoverer
|
|
6
|
+
* - roleRefiner
|
|
7
|
+
* - couplingAnalyzer
|
|
8
|
+
* - layerInferrer
|
|
9
|
+
* - panoramaAggregator
|
|
10
|
+
* - panoramaScanner
|
|
11
|
+
* - panoramaService
|
|
12
|
+
*
|
|
13
|
+
* @module PanoramaModule
|
|
14
|
+
*/
|
|
15
|
+
import { CouplingAnalyzer } from '../../service/panorama/CouplingAnalyzer.js';
|
|
16
|
+
import { DimensionAnalyzer } from '../../service/panorama/DimensionAnalyzer.js';
|
|
17
|
+
import { LayerInferrer } from '../../service/panorama/LayerInferrer.js';
|
|
18
|
+
import { ModuleDiscoverer } from '../../service/panorama/ModuleDiscoverer.js';
|
|
19
|
+
import { PanoramaAggregator } from '../../service/panorama/PanoramaAggregator.js';
|
|
20
|
+
import { PanoramaScanner } from '../../service/panorama/PanoramaScanner.js';
|
|
21
|
+
import { PanoramaService } from '../../service/panorama/PanoramaService.js';
|
|
22
|
+
import { RoleRefiner } from '../../service/panorama/RoleRefiner.js';
|
|
23
|
+
export const PanoramaModule = {
|
|
24
|
+
register(container) {
|
|
25
|
+
const ct = container;
|
|
26
|
+
const getDb = () => {
|
|
27
|
+
const db = ct.singletons.database;
|
|
28
|
+
return (db?.getDb ? db.getDb() : db);
|
|
29
|
+
};
|
|
30
|
+
const getProjectRoot = () => ct.config?.projectRoot ?? process.cwd();
|
|
31
|
+
ct.singleton('moduleDiscoverer', () => new ModuleDiscoverer(getDb(), getProjectRoot()));
|
|
32
|
+
ct.singleton('roleRefiner', () => new RoleRefiner(getDb(), getProjectRoot()));
|
|
33
|
+
ct.singleton('couplingAnalyzer', () => new CouplingAnalyzer(getDb(), getProjectRoot()));
|
|
34
|
+
ct.singleton('layerInferrer', () => new LayerInferrer());
|
|
35
|
+
ct.singleton('dimensionAnalyzer', () => new DimensionAnalyzer(getDb()));
|
|
36
|
+
ct.singleton('panoramaAggregator', (c) => {
|
|
37
|
+
const sc = c;
|
|
38
|
+
const roleRefiner = sc.get('roleRefiner');
|
|
39
|
+
const couplingAnalyzer = sc.get('couplingAnalyzer');
|
|
40
|
+
const layerInferrer = sc.get('layerInferrer');
|
|
41
|
+
const dimensionAnalyzer = sc.get('dimensionAnalyzer');
|
|
42
|
+
return new PanoramaAggregator({
|
|
43
|
+
roleRefiner,
|
|
44
|
+
couplingAnalyzer,
|
|
45
|
+
layerInferrer,
|
|
46
|
+
db: getDb(),
|
|
47
|
+
projectRoot: getProjectRoot(),
|
|
48
|
+
dimensionAnalyzer,
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
ct.singleton('panoramaScanner', () => {
|
|
52
|
+
const logger = (ct.singletons.logger ?? {
|
|
53
|
+
info() { },
|
|
54
|
+
warn() { },
|
|
55
|
+
});
|
|
56
|
+
return new PanoramaScanner({
|
|
57
|
+
projectRoot: getProjectRoot(),
|
|
58
|
+
container: container,
|
|
59
|
+
logger,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
ct.singleton('panoramaService', (c) => {
|
|
63
|
+
const sc = c;
|
|
64
|
+
const aggregator = sc.get('panoramaAggregator');
|
|
65
|
+
const scanner = sc.get('panoramaScanner');
|
|
66
|
+
const moduleDiscoverer = sc.get('moduleDiscoverer');
|
|
67
|
+
return new PanoramaService({
|
|
68
|
+
aggregator,
|
|
69
|
+
db: getDb(),
|
|
70
|
+
projectRoot: getProjectRoot(),
|
|
71
|
+
scanner,
|
|
72
|
+
moduleDiscoverer,
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SignalModule — Phase 0 信号基础设施注册
|
|
3
|
+
*
|
|
4
|
+
* 注册:
|
|
5
|
+
* - signalBus: 统一信号总线(基础设施层)
|
|
6
|
+
* - hitRecorder: 批量使用信号采集器(服务层)
|
|
7
|
+
* - intent JSONL persistence subscriber
|
|
8
|
+
*/
|
|
9
|
+
import type { ServiceContainer } from '../ServiceContainer.js';
|
|
10
|
+
export declare function register(c: ServiceContainer): void;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SignalModule — Phase 0 信号基础设施注册
|
|
3
|
+
*
|
|
4
|
+
* 注册:
|
|
5
|
+
* - signalBus: 统一信号总线(基础设施层)
|
|
6
|
+
* - hitRecorder: 批量使用信号采集器(服务层)
|
|
7
|
+
* - intent JSONL persistence subscriber
|
|
8
|
+
*/
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { SignalAggregator } from '../../infrastructure/signal/SignalAggregator.js';
|
|
12
|
+
import { SignalBridge } from '../../infrastructure/signal/SignalBridge.js';
|
|
13
|
+
import { SignalBus } from '../../infrastructure/signal/SignalBus.js';
|
|
14
|
+
import { SignalTraceWriter } from '../../infrastructure/signal/SignalTraceWriter.js';
|
|
15
|
+
import { HitRecorder } from '../../service/signal/HitRecorder.js';
|
|
16
|
+
import { resolveProjectRoot } from '../../shared/resolveProjectRoot.js';
|
|
17
|
+
import { shutdown } from '../../shared/shutdown.js';
|
|
18
|
+
/**
|
|
19
|
+
* Register intent signal subscriber for JSONL persistence.
|
|
20
|
+
* Replaces standalone SignalLogger — writes IntentChainRecord to .autosnippet/logs/signals/YYYY-MM-DD.jsonl.
|
|
21
|
+
*/
|
|
22
|
+
function registerIntentPersistence(signalBus, projectRoot) {
|
|
23
|
+
signalBus.subscribe('intent', (signal) => {
|
|
24
|
+
try {
|
|
25
|
+
const chain = signal.metadata?.chain;
|
|
26
|
+
if (!chain) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const dir = path.join(projectRoot, '.autosnippet', 'logs', 'signals');
|
|
30
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
31
|
+
const d = new Date(signal.timestamp);
|
|
32
|
+
const dateStr = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
|
33
|
+
const filePath = path.join(dir, `${dateStr}.jsonl`);
|
|
34
|
+
fs.appendFileSync(filePath, `${JSON.stringify(chain)}\n`, 'utf8');
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Write failure is non-blocking
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export function register(c) {
|
|
42
|
+
// ═══ Infrastructure ═══
|
|
43
|
+
c.singleton('signalBus', () => new SignalBus());
|
|
44
|
+
// ═══ Service ═══
|
|
45
|
+
c.singleton('hitRecorder', (ct) => {
|
|
46
|
+
const bus = ct.get('signalBus');
|
|
47
|
+
const db = ct.get('database');
|
|
48
|
+
const recorder = new HitRecorder(bus, db);
|
|
49
|
+
recorder.start();
|
|
50
|
+
// shutdown hook: 在 DB close 之前 flush buffer
|
|
51
|
+
shutdown.register(async () => {
|
|
52
|
+
await recorder.stop();
|
|
53
|
+
}, 'hitRecorder');
|
|
54
|
+
return recorder;
|
|
55
|
+
});
|
|
56
|
+
// ═══ Intent Signal Persistence ═══
|
|
57
|
+
// Register after signalBus is created — subscribe for JSONL persistence
|
|
58
|
+
const signalBus = c.get('signalBus');
|
|
59
|
+
const projectRoot = resolveProjectRoot(c);
|
|
60
|
+
registerIntentPersistence(signalBus, projectRoot);
|
|
61
|
+
// ═══ SignalBridge — SignalBus → EventBus 桥接 ═══
|
|
62
|
+
c.singleton('signalBridge', (ct) => {
|
|
63
|
+
const bus = ct.get('signalBus');
|
|
64
|
+
const eventBus = ct.get('eventBus');
|
|
65
|
+
return new SignalBridge(bus, eventBus);
|
|
66
|
+
});
|
|
67
|
+
// ═══ SignalTraceWriter — 全类型信号 JSONL 留痕 ═══
|
|
68
|
+
c.singleton('signalTraceWriter', (ct) => {
|
|
69
|
+
const bus = ct.get('signalBus');
|
|
70
|
+
const root = resolveProjectRoot(ct);
|
|
71
|
+
return new SignalTraceWriter(bus, path.join(root, '.autosnippet', 'logs', 'signals'));
|
|
72
|
+
});
|
|
73
|
+
// ═══ SignalAggregator — 滑窗统计 + 异常检测 ═══
|
|
74
|
+
c.singleton('signalAggregator', (ct) => {
|
|
75
|
+
const bus = ct.get('signalBus');
|
|
76
|
+
const reportStore = ct.get('reportStore');
|
|
77
|
+
const agg = new SignalAggregator(bus, reportStore);
|
|
78
|
+
agg.start();
|
|
79
|
+
shutdown.register(async () => {
|
|
80
|
+
agg.stop();
|
|
81
|
+
}, 'signalAggregator');
|
|
82
|
+
return agg;
|
|
83
|
+
});
|
|
84
|
+
}
|