autosnippet 3.3.6 → 3.3.8
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 +1 -0
- package/dashboard/dist/assets/icons-BMNb0V6L.js +1 -0
- package/dashboard/dist/assets/index-DHJ1Dj7u.css +1 -0
- package/dashboard/dist/assets/index-DV8biUkH.js +112 -0
- package/dashboard/dist/index.html +3 -3
- package/dist/bin/cli.js +8 -4
- package/dist/lib/agent/AgentRuntime.d.ts +2 -2
- package/dist/lib/agent/AgentRuntime.js +26 -18
- package/dist/lib/agent/core/ChatAgentPrompts.js +57 -21
- package/dist/lib/agent/core/LoopContext.d.ts +1 -0
- package/dist/lib/agent/core/ToolExecutionPipeline.js +13 -0
- package/dist/lib/agent/domain/ChatAgentTasks.js +4 -0
- package/dist/lib/agent/forced-summary.js +7 -2
- package/dist/lib/agent/memory/ActiveContext.d.ts +0 -2
- package/dist/lib/agent/memory/ActiveContext.js +0 -2
- package/dist/lib/agent/memory/MemoryEmbeddingStore.d.ts +49 -0
- package/dist/lib/agent/memory/MemoryEmbeddingStore.js +159 -0
- package/dist/lib/agent/memory/MemoryRetriever.d.ts +2 -0
- package/dist/lib/agent/memory/MemoryRetriever.js +25 -11
- package/dist/lib/agent/memory/MemoryStore.d.ts +8 -41
- package/dist/lib/agent/memory/MemoryStore.js +196 -261
- package/dist/lib/agent/memory/PersistentMemory.d.ts +2 -0
- package/dist/lib/agent/memory/PersistentMemory.js +4 -5
- package/dist/lib/agent/memory/SessionStore.d.ts +0 -2
- package/dist/lib/agent/memory/SessionStore.js +0 -2
- package/dist/lib/agent/tools/ast-graph.js +21 -19
- package/dist/lib/agent/tools/infrastructure.js +3 -2
- package/dist/lib/agent/tools/project-access.d.ts +2 -2
- package/dist/lib/agent/tools/project-access.js +5 -4
- package/dist/lib/bootstrap.js +2 -1
- package/dist/lib/cli/AiScanService.js +8 -21
- package/dist/lib/cli/KnowledgeSyncService.d.ts +7 -37
- package/dist/lib/cli/KnowledgeSyncService.js +23 -51
- package/dist/lib/core/ast/ProjectGraph.js +5 -27
- package/dist/lib/core/discovery/ConfigWatcher.d.ts +64 -0
- package/dist/lib/core/discovery/ConfigWatcher.js +336 -0
- package/dist/lib/core/discovery/CustomConfigDiscoverer.d.ts +28 -0
- package/dist/lib/core/discovery/CustomConfigDiscoverer.js +1303 -0
- package/dist/lib/core/discovery/DiscovererPreference.d.ts +44 -0
- package/dist/lib/core/discovery/DiscovererPreference.js +141 -0
- package/dist/lib/core/discovery/DiscovererRegistry.d.ts +10 -1
- package/dist/lib/core/discovery/DiscovererRegistry.js +42 -2
- package/dist/lib/core/discovery/ProjectDiscoverer.d.ts +19 -0
- package/dist/lib/core/discovery/index.d.ts +2 -0
- package/dist/lib/core/discovery/index.js +4 -0
- package/dist/lib/core/discovery/parsers/CMakeParser.d.ts +32 -0
- package/dist/lib/core/discovery/parsers/CMakeParser.js +148 -0
- package/dist/lib/core/discovery/parsers/GradleDslParser.d.ts +43 -0
- package/dist/lib/core/discovery/parsers/GradleDslParser.js +171 -0
- package/dist/lib/core/discovery/parsers/JsonConfigParser.d.ts +45 -0
- package/dist/lib/core/discovery/parsers/JsonConfigParser.js +122 -0
- package/dist/lib/core/discovery/parsers/RubyDslParser.d.ts +49 -0
- package/dist/lib/core/discovery/parsers/RubyDslParser.js +282 -0
- package/dist/lib/core/discovery/parsers/StarlarkParser.d.ts +33 -0
- package/dist/lib/core/discovery/parsers/StarlarkParser.js +229 -0
- package/dist/lib/core/discovery/parsers/YamlConfigParser.d.ts +37 -0
- package/dist/lib/core/discovery/parsers/YamlConfigParser.js +212 -0
- package/dist/lib/domain/dimension/DimensionRegistry.d.ts +0 -2
- package/dist/lib/domain/dimension/DimensionRegistry.js +0 -2
- package/dist/lib/domain/dimension/DimensionSop.js +44 -33
- package/dist/lib/domain/dimension/UnifiedDimension.d.ts +0 -2
- package/dist/lib/domain/dimension/UnifiedDimension.js +0 -2
- package/dist/lib/domain/knowledge/KnowledgeEntry.d.ts +7 -1
- package/dist/lib/domain/knowledge/KnowledgeEntry.js +17 -3
- package/dist/lib/domain/knowledge/Lifecycle.d.ts +26 -0
- package/dist/lib/domain/knowledge/Lifecycle.js +42 -0
- package/dist/lib/domain/knowledge/index.d.ts +2 -1
- package/dist/lib/domain/knowledge/index.js +1 -1
- package/dist/lib/external/ai/AiProvider.d.ts +12 -0
- package/dist/lib/external/ai/AiProvider.js +24 -0
- package/dist/lib/external/ai/AiProviderManager.d.ts +101 -0
- package/dist/lib/external/ai/AiProviderManager.js +193 -0
- package/dist/lib/external/ai/providers/ClaudeProvider.js +11 -0
- package/dist/lib/external/ai/providers/GoogleGeminiProvider.js +18 -0
- package/dist/lib/external/ai/providers/MockProvider.d.ts +21 -3
- package/dist/lib/external/ai/providers/MockProvider.js +290 -14
- package/dist/lib/external/ai/providers/OpenAiProvider.js +16 -0
- package/dist/lib/external/lark/LarkTransport.d.ts +5 -1
- package/dist/lib/external/lark/LarkTransport.js +10 -2
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.d.ts +2 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.js +102 -153
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/mock-pipeline.d.ts +20 -0
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/mock-pipeline.js +432 -0
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +49 -24
- package/dist/lib/external/mcp/handlers/bootstrap/refine.js +8 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.d.ts +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +41 -37
- package/dist/lib/external/mcp/handlers/bootstrap-external.d.ts +9 -0
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +3 -1
- package/dist/lib/external/mcp/handlers/bootstrap-internal.js +2 -0
- package/dist/lib/external/mcp/handlers/consolidated.js +2 -1
- package/dist/lib/external/mcp/handlers/dimension-complete-external.js +9 -4
- package/dist/lib/external/mcp/handlers/evolve-external.d.ts +1 -0
- package/dist/lib/external/mcp/handlers/evolve-external.js +18 -18
- package/dist/lib/external/mcp/handlers/guard.js +15 -24
- package/dist/lib/external/mcp/handlers/knowledge.js +5 -4
- package/dist/lib/external/mcp/handlers/panorama.js +9 -9
- package/dist/lib/external/mcp/handlers/rescan-external.js +7 -6
- package/dist/lib/external/mcp/handlers/rescan-internal.js +9 -5
- package/dist/lib/external/mcp/handlers/search.js +3 -1
- package/dist/lib/external/mcp/handlers/skill.js +4 -4
- package/dist/lib/external/mcp/handlers/structure.js +8 -12
- package/dist/lib/external/mcp/handlers/system.js +10 -34
- package/dist/lib/http/routes/ai.js +109 -30
- package/dist/lib/http/routes/candidates.js +11 -4
- package/dist/lib/http/routes/commands.js +10 -1
- package/dist/lib/http/routes/guardReport.js +3 -5
- package/dist/lib/http/routes/health.js +11 -0
- package/dist/lib/http/routes/modules.js +27 -0
- package/dist/lib/http/routes/panorama.js +12 -12
- package/dist/lib/http/routes/recipes.js +66 -8
- package/dist/lib/http/routes/remote.js +3 -13
- package/dist/lib/http/routes/search.js +11 -8
- package/dist/lib/http/utils/routeHelpers.js +2 -1
- package/dist/lib/infrastructure/audit/AuditLogger.d.ts +20 -3
- package/dist/lib/infrastructure/audit/AuditStore.d.ts +28 -29
- package/dist/lib/infrastructure/audit/AuditStore.js +81 -88
- package/dist/lib/infrastructure/database/drizzle/schema.d.ts +180 -2
- package/dist/lib/infrastructure/database/drizzle/schema.js +23 -3
- package/dist/lib/injection/ServiceContainer.d.ts +6 -5
- package/dist/lib/injection/ServiceContainer.js +18 -31
- package/dist/lib/injection/ServiceMap.d.ts +22 -0
- package/dist/lib/injection/modules/AiModule.d.ts +6 -9
- package/dist/lib/injection/modules/AiModule.js +82 -39
- package/dist/lib/injection/modules/AppModule.js +2 -1
- package/dist/lib/injection/modules/GuardModule.js +5 -5
- package/dist/lib/injection/modules/InfraModule.js +60 -0
- package/dist/lib/injection/modules/KnowledgeModule.js +86 -51
- package/dist/lib/injection/modules/PanoramaModule.js +16 -10
- package/dist/lib/injection/modules/VectorModule.js +3 -0
- package/dist/lib/repository/audit/AuditRepository.d.ts +107 -0
- package/dist/lib/repository/audit/AuditRepository.js +272 -0
- package/dist/lib/repository/base/RepositoryBase.d.ts +46 -0
- package/dist/lib/repository/base/RepositoryBase.js +32 -0
- package/dist/lib/repository/bootstrap/BootstrapRepository.d.ts +94 -0
- package/dist/lib/repository/bootstrap/BootstrapRepository.js +246 -0
- package/dist/lib/repository/code/CodeEntityRepository.d.ts +91 -0
- package/dist/lib/repository/code/CodeEntityRepository.js +361 -0
- package/dist/lib/repository/delivery/DeliveryRepoAdapter.d.ts +39 -0
- package/dist/lib/repository/delivery/DeliveryRepoAdapter.js +23 -0
- package/dist/lib/repository/evolution/LifecycleEventRepository.d.ts +51 -0
- package/dist/lib/repository/evolution/LifecycleEventRepository.js +119 -0
- package/dist/lib/repository/evolution/ProposalRepository.d.ts +9 -12
- package/dist/lib/repository/evolution/ProposalRepository.js +114 -57
- package/dist/lib/repository/guard/GuardViolationRepository.d.ts +104 -0
- package/dist/lib/repository/guard/GuardViolationRepository.js +217 -0
- package/dist/lib/repository/knowledge/KnowledgeEdgeRepository.d.ts +129 -0
- package/dist/lib/repository/knowledge/KnowledgeEdgeRepository.js +475 -0
- package/dist/lib/repository/knowledge/KnowledgeFileStore.d.ts +39 -0
- package/dist/lib/repository/knowledge/KnowledgeFileStore.js +12 -0
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.d.ts +295 -11
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.js +608 -13
- package/dist/lib/repository/knowledge/KnowledgeUnitOfWork.d.ts +61 -0
- package/dist/lib/repository/knowledge/KnowledgeUnitOfWork.js +156 -0
- package/dist/lib/repository/memory/MemoryRepository.d.ts +90 -0
- package/dist/lib/repository/memory/MemoryRepository.js +260 -0
- package/dist/lib/repository/search/SearchRepoAdapter.d.ts +92 -0
- package/dist/lib/repository/search/SearchRepoAdapter.js +124 -0
- package/dist/lib/repository/session/SessionRepository.d.ts +46 -0
- package/dist/lib/repository/session/SessionRepository.js +110 -0
- package/dist/lib/repository/sourceref/RecipeSourceRefRepository.d.ts +66 -0
- package/dist/lib/repository/sourceref/RecipeSourceRefRepository.js +182 -0
- package/dist/lib/repository/sync/SyncRepoAdapter.d.ts +58 -0
- package/dist/lib/repository/sync/SyncRepoAdapter.js +58 -0
- package/dist/lib/service/bootstrap/UiStartupTasks.js +5 -6
- package/dist/lib/service/bootstrap/bootstrap-event-types.d.ts +0 -1
- package/dist/lib/service/bootstrap/bootstrap-event-types.js +0 -1
- package/dist/lib/service/cleanup/CleanupService.d.ts +54 -7
- package/dist/lib/service/cleanup/CleanupService.js +291 -40
- package/dist/lib/service/delivery/CursorDeliveryPipeline.js +6 -8
- package/dist/lib/service/evolution/ConsolidationAdvisor.d.ts +4 -9
- package/dist/lib/service/evolution/ConsolidationAdvisor.js +34 -70
- package/dist/lib/service/evolution/ContentPatcher.d.ts +4 -12
- package/dist/lib/service/evolution/ContentPatcher.js +48 -19
- package/dist/lib/service/evolution/ContradictionDetector.d.ts +3 -7
- package/dist/lib/service/evolution/ContradictionDetector.js +17 -24
- package/dist/lib/service/evolution/DecayDetector.d.ts +10 -9
- package/dist/lib/service/evolution/DecayDetector.js +63 -57
- package/dist/lib/service/evolution/EnhancementSuggester.d.ts +3 -9
- package/dist/lib/service/evolution/EnhancementSuggester.js +42 -86
- package/dist/lib/service/evolution/KnowledgeMetabolism.d.ts +4 -4
- package/dist/lib/service/evolution/KnowledgeMetabolism.js +102 -71
- package/dist/lib/service/evolution/ProposalExecutor.d.ts +5 -12
- package/dist/lib/service/evolution/ProposalExecutor.js +64 -69
- package/dist/lib/service/evolution/RecipeLifecycleSupervisor.d.ts +9 -14
- package/dist/lib/service/evolution/RecipeLifecycleSupervisor.js +94 -155
- package/dist/lib/service/evolution/RecipeRelevanceAuditor.d.ts +4 -1
- package/dist/lib/service/evolution/RecipeRelevanceAuditor.js +50 -49
- package/dist/lib/service/evolution/RedundancyAnalyzer.d.ts +3 -7
- package/dist/lib/service/evolution/RedundancyAnalyzer.js +15 -22
- package/dist/lib/service/evolution/StagingManager.d.ts +6 -15
- package/dist/lib/service/evolution/StagingManager.js +37 -95
- package/dist/lib/service/evolution/createSupersedeProposal.d.ts +1 -1
- package/dist/lib/service/evolution/createSupersedeProposal.js +7 -8
- package/dist/lib/service/guard/CoverageAnalyzer.d.ts +3 -7
- package/dist/lib/service/guard/CoverageAnalyzer.js +9 -11
- package/dist/lib/service/guard/GuardCheckEngine.d.ts +3 -0
- package/dist/lib/service/guard/GuardCheckEngine.js +14 -22
- package/dist/lib/service/guard/ReverseGuard.d.ts +4 -7
- package/dist/lib/service/guard/ReverseGuard.js +21 -31
- package/dist/lib/service/guard/ViolationsStore.d.ts +15 -21
- package/dist/lib/service/guard/ViolationsStore.js +75 -69
- package/dist/lib/service/knowledge/CodeEntityGraph.d.ts +45 -63
- package/dist/lib/service/knowledge/CodeEntityGraph.js +418 -496
- package/dist/lib/service/knowledge/ConfidenceRouter.js +18 -9
- package/dist/lib/service/knowledge/KnowledgeFileWriter.d.ts +2 -1
- package/dist/lib/service/knowledge/KnowledgeGraphService.d.ts +18 -60
- package/dist/lib/service/knowledge/KnowledgeGraphService.js +58 -109
- package/dist/lib/service/knowledge/KnowledgeService.d.ts +15 -1
- package/dist/lib/service/knowledge/KnowledgeService.js +97 -46
- package/dist/lib/service/knowledge/RecipeProductionGateway.d.ts +0 -2
- package/dist/lib/service/knowledge/RecipeProductionGateway.js +0 -2
- package/dist/lib/service/knowledge/SourceRefReconciler.d.ts +5 -13
- package/dist/lib/service/knowledge/SourceRefReconciler.js +58 -78
- package/dist/lib/service/module/ModuleService.js +10 -19
- package/dist/lib/service/panorama/CouplingAnalyzer.d.ts +14 -3
- package/dist/lib/service/panorama/CouplingAnalyzer.js +137 -32
- package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +7 -4
- package/dist/lib/service/panorama/DimensionAnalyzer.js +94 -33
- package/dist/lib/service/panorama/LayerInferrer.d.ts +16 -1
- package/dist/lib/service/panorama/LayerInferrer.js +118 -1
- package/dist/lib/service/panorama/ModuleDiscoverer.d.ts +14 -4
- package/dist/lib/service/panorama/ModuleDiscoverer.js +209 -61
- package/dist/lib/service/panorama/PanoramaAggregator.d.ts +15 -4
- package/dist/lib/service/panorama/PanoramaAggregator.js +128 -62
- package/dist/lib/service/panorama/PanoramaScanner.d.ts +5 -1
- package/dist/lib/service/panorama/PanoramaScanner.js +60 -31
- package/dist/lib/service/panorama/PanoramaService.d.ts +11 -8
- package/dist/lib/service/panorama/PanoramaService.js +49 -69
- package/dist/lib/service/panorama/PanoramaTypes.d.ts +41 -0
- package/dist/lib/service/panorama/RoleRefiner.d.ts +10 -5
- package/dist/lib/service/panorama/RoleRefiner.js +92 -282
- package/dist/lib/service/panorama/TechStackProfiler.d.ts +13 -0
- package/dist/lib/service/panorama/TechStackProfiler.js +79 -0
- package/dist/lib/service/quality/QualityScorer.d.ts +45 -26
- package/dist/lib/service/quality/QualityScorer.js +157 -83
- package/dist/lib/service/search/SearchEngine.d.ts +1 -0
- package/dist/lib/service/search/SearchEngine.js +32 -37
- package/dist/lib/service/signal/HitRecorder.js +5 -5
- package/dist/lib/service/skills/RuleRecallStrategy.js +7 -3
- package/dist/lib/service/skills/SignalCollector.d.ts +6 -8
- package/dist/lib/service/skills/SignalCollector.js +34 -60
- package/dist/lib/service/skills/SkillAdvisor.d.ts +7 -13
- package/dist/lib/service/skills/SkillAdvisor.js +30 -79
- package/dist/lib/service/vector/ContextualEnricher.d.ts +1 -0
- package/dist/lib/service/vector/ContextualEnricher.js +4 -0
- package/dist/lib/service/vector/SyncCoordinator.d.ts +3 -1
- package/dist/lib/service/vector/SyncCoordinator.js +25 -3
- package/dist/lib/service/vector/VectorService.d.ts +2 -0
- package/dist/lib/service/vector/VectorService.js +3 -0
- package/dist/lib/service/wiki/WikiGenerator.js +1 -1
- package/dist/lib/shared/LanguageProfiles.d.ts +109 -0
- package/dist/lib/shared/LanguageProfiles.js +939 -0
- package/dist/lib/shared/LanguageService.d.ts +6 -0
- package/dist/lib/shared/LanguageService.js +19 -0
- package/dist/lib/shared/constants.d.ts +19 -19
- package/dist/lib/shared/constants.js +10 -10
- package/dist/lib/shared/developer-identity.d.ts +18 -0
- package/dist/lib/shared/developer-identity.js +62 -0
- package/dist/lib/shared/schemas/http-requests.d.ts +8 -17
- package/dist/lib/shared/schemas/http-requests.js +9 -6
- package/dist/lib/shared/schemas/mcp-tools.d.ts +1 -1
- package/dist/lib/types/knowledge-wire.d.ts +1 -0
- package/dist/lib/types/project-snapshot-builder.d.ts +0 -1
- package/dist/lib/types/project-snapshot-builder.js +0 -1
- package/dist/lib/types/project-snapshot.d.ts +0 -1
- package/dist/lib/types/project-snapshot.js +0 -1
- package/dist/lib/types/snapshot-views.d.ts +0 -2
- package/dist/lib/types/snapshot-views.js +0 -1
- package/package.json +2 -1
- package/dashboard/dist/assets/icons-D1aVZYFW.js +0 -1
- package/dashboard/dist/assets/index-CxHOu8Hd.css +0 -1
- package/dashboard/dist/assets/index-DDdAOpYT.js +0 -128
- package/dist/lib/repository/base/BaseRepository.d.ts +0 -53
- package/dist/lib/repository/base/BaseRepository.js +0 -226
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Phase 1 → 文件收集(DiscovererRegistry → 多语言项目类型检测)
|
|
10
10
|
* Phase 1.5 → AST 代码结构分析(tree-sitter + SFC 预处理)
|
|
11
11
|
* Phase 1.6 → Code Entity Graph(代码实体关系图谱)
|
|
12
|
-
* Phase
|
|
12
|
+
* Phase 2.2 → Panorama 全景汇总(RoleRefiner + CouplingAnalyzer + LayerInferrer)
|
|
13
13
|
* Phase 2 → 依赖关系 → knowledge_edges
|
|
14
14
|
* Phase 2.1 → Module 实体写入 Entity Graph
|
|
15
15
|
* Phase 3 → Guard 规则审计
|
|
@@ -218,12 +218,13 @@ export async function runPhase1_6_EntityGraph(astProjectSummary, projectRoot, co
|
|
|
218
218
|
if (astProjectSummary) {
|
|
219
219
|
try {
|
|
220
220
|
const { CodeEntityGraph } = await import('#service/knowledge/CodeEntityGraph.js');
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
ceg
|
|
221
|
+
const entityRepo = container.get('codeEntityRepository');
|
|
222
|
+
const edgeRepo = container.get('knowledgeEdgeRepository');
|
|
223
|
+
if (entityRepo && edgeRepo) {
|
|
224
|
+
const ceg = new CodeEntityGraph(entityRepo, edgeRepo, { projectRoot });
|
|
225
|
+
await ceg.clearProject();
|
|
225
226
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- ProjectAnalysisResult structurally compatible at runtime
|
|
226
|
-
codeEntityResult = ceg.populateFromAst(astProjectSummary);
|
|
227
|
+
codeEntityResult = await ceg.populateFromAst(astProjectSummary);
|
|
227
228
|
logger.info(`[Bootstrap] Entity Graph: ${codeEntityResult.entitiesUpserted} entities, ${codeEntityResult.edgesCreated} edges`);
|
|
228
229
|
}
|
|
229
230
|
}
|
|
@@ -279,14 +280,15 @@ export async function runPhase1_7_CallGraph(astProjectSummary, projectRoot, cont
|
|
|
279
280
|
minConfidence: 0.5,
|
|
280
281
|
});
|
|
281
282
|
// 写入 CodeEntityGraph
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
const entityRepo = container.get('codeEntityRepository');
|
|
284
|
+
const edgeRepo = container.get('knowledgeEdgeRepository');
|
|
285
|
+
if (entityRepo && edgeRepo && result && result.callEdges.length > 0) {
|
|
286
|
+
const ceg = new CodeEntityGraph(entityRepo, edgeRepo, { projectRoot });
|
|
285
287
|
// 增量模式: 先删除变更文件的旧边
|
|
286
288
|
if (isIncremental) {
|
|
287
|
-
ceg.clearCallGraphForFiles(changedFiles ?? null);
|
|
289
|
+
await ceg.clearCallGraphForFiles(changedFiles ?? null);
|
|
288
290
|
}
|
|
289
|
-
callGraphResult = ceg.populateCallGraph(result.callEdges, result.dataFlowEdges);
|
|
291
|
+
callGraphResult = await ceg.populateCallGraph(result.callEdges, result.dataFlowEdges);
|
|
290
292
|
const partialTag = result.stats.partial ? ' [partial]' : '';
|
|
291
293
|
const incrTag = isIncremental ? ' [incremental]' : '';
|
|
292
294
|
logger.info(`[Bootstrap] Call Graph${incrTag}${partialTag}: ${result.callEdges.length} call edges, ` +
|
|
@@ -321,7 +323,7 @@ export async function runPhase2_DependencyGraph(discoverer, container, logger, s
|
|
|
321
323
|
depGraphData = await discoverer.getDependencyGraph();
|
|
322
324
|
if (knowledgeGraphService) {
|
|
323
325
|
for (const edge of depGraphData.edges || []) {
|
|
324
|
-
const result = knowledgeGraphService.addEdge(edge.from, 'module', edge.to, 'module', 'depends_on', { weight: 1.0, source: `${discoverer.id}-${sourceTag}` });
|
|
326
|
+
const result = await knowledgeGraphService.addEdge(edge.from, 'module', edge.to, 'module', 'depends_on', { weight: 1.0, source: `${discoverer.id}-${sourceTag}` });
|
|
325
327
|
if (result?.success) {
|
|
326
328
|
depEdgesWritten++;
|
|
327
329
|
}
|
|
@@ -346,10 +348,11 @@ export async function runPhase2_1_ModuleEntities(depGraphData, projectRoot, cont
|
|
|
346
348
|
}
|
|
347
349
|
try {
|
|
348
350
|
const { CodeEntityGraph } = await import('#service/knowledge/CodeEntityGraph.js');
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
const
|
|
351
|
+
const entityRepo = container.get('codeEntityRepository');
|
|
352
|
+
const edgeRepo = container.get('knowledgeEdgeRepository');
|
|
353
|
+
if (entityRepo && edgeRepo) {
|
|
354
|
+
const ceg = new CodeEntityGraph(entityRepo, edgeRepo, { projectRoot });
|
|
355
|
+
const result = await ceg.populateFromSpm(depGraphData);
|
|
353
356
|
logger.info(`[Bootstrap] Entity Graph modules: ${result.entitiesUpserted} entities`);
|
|
354
357
|
}
|
|
355
358
|
}
|
|
@@ -637,42 +640,43 @@ export async function runAllPhases(projectRoot, ctx, options = {}) {
|
|
|
637
640
|
if (report) {
|
|
638
641
|
report.phases.callGraph = { result: phase1_7.callGraphResult, ms: Date.now() - p17Start };
|
|
639
642
|
}
|
|
640
|
-
// ── Phase
|
|
643
|
+
// ── Phase 2: 依赖图 ──
|
|
644
|
+
const p2Start = Date.now();
|
|
645
|
+
const phase2 = await runPhase2_DependencyGraph(discoverer, ctx.container, ctx.logger, options.sourceTag || 'bootstrap');
|
|
646
|
+
warnings.push(...phase2.warnings);
|
|
647
|
+
if (report) {
|
|
648
|
+
report.phases.depGraph = {
|
|
649
|
+
edgesWritten: phase2.depEdgesWritten || 0,
|
|
650
|
+
ms: Date.now() - p2Start,
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
// ── Phase 2.1: Module 实体 ──
|
|
654
|
+
await runPhase2_1_ModuleEntities(phase2.depGraphData, projectRoot, ctx.container, ctx.logger);
|
|
655
|
+
// ── Phase 2.2: Panorama 全景汇总 ──
|
|
656
|
+
// 必须在 Phase 2.1 之后:此时 code_entities 中已有 module 记录
|
|
641
657
|
let panoramaResult = null;
|
|
642
658
|
try {
|
|
643
|
-
const panoramaService = ctx.container
|
|
659
|
+
const panoramaService = ctx.container.get('panoramaService');
|
|
644
660
|
if (panoramaService &&
|
|
645
661
|
typeof panoramaService.invalidate === 'function') {
|
|
646
|
-
const
|
|
662
|
+
const pPanoStart = Date.now();
|
|
647
663
|
panoramaService.invalidate();
|
|
648
|
-
const result = panoramaService.getResult();
|
|
664
|
+
const result = await panoramaService.getResult();
|
|
649
665
|
panoramaResult = result;
|
|
650
|
-
ctx.logger.info(`[Bootstrap] Phase
|
|
666
|
+
ctx.logger.info(`[Bootstrap] Phase 2.2: Panorama computed in ${Date.now() - pPanoStart}ms`);
|
|
651
667
|
if (report) {
|
|
652
|
-
const overview = panoramaService.getOverview();
|
|
668
|
+
const overview = await panoramaService.getOverview();
|
|
653
669
|
report.phases.panorama = {
|
|
654
670
|
moduleCount: overview.moduleCount ?? 0,
|
|
655
671
|
layerCount: overview.layerCount ?? 0,
|
|
656
|
-
ms: Date.now() -
|
|
672
|
+
ms: Date.now() - pPanoStart,
|
|
657
673
|
};
|
|
658
674
|
}
|
|
659
675
|
}
|
|
660
676
|
}
|
|
661
677
|
catch (err) {
|
|
662
|
-
warnings.push(`Phase
|
|
678
|
+
warnings.push(`Phase 2.2 panorama failed (non-blocking): ${err instanceof Error ? err.message : String(err)}`);
|
|
663
679
|
}
|
|
664
|
-
// ── Phase 2: 依赖图 ──
|
|
665
|
-
const p2Start = Date.now();
|
|
666
|
-
const phase2 = await runPhase2_DependencyGraph(discoverer, ctx.container, ctx.logger, options.sourceTag || 'bootstrap');
|
|
667
|
-
warnings.push(...phase2.warnings);
|
|
668
|
-
if (report) {
|
|
669
|
-
report.phases.depGraph = {
|
|
670
|
-
edgesWritten: phase2.depEdgesWritten || 0,
|
|
671
|
-
ms: Date.now() - p2Start,
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
// ── Phase 2.1: Module 实体 ──
|
|
675
|
-
await runPhase2_1_ModuleEntities(phase2.depGraphData, projectRoot, ctx.container, ctx.logger);
|
|
676
680
|
// ── Phase 3: Guard 审计 ──
|
|
677
681
|
const p3Start = Date.now();
|
|
678
682
|
const phase3 = await runPhase3_GuardAudit(allFiles, ctx.container, ctx.logger, {
|
|
@@ -766,7 +770,7 @@ export async function runAllPhases(projectRoot, ctx, options = {}) {
|
|
|
766
770
|
warnings,
|
|
767
771
|
report, // NEW: Phase 级报告 (null if generateReport=false)
|
|
768
772
|
incrementalPlan, // NEW: 增量评估结果 (null if incremental=false)
|
|
769
|
-
panoramaResult, // Phase
|
|
773
|
+
panoramaResult, // Phase 2.2: 全景汇总 (null if panoramaService unavailable)
|
|
770
774
|
isEmpty: false,
|
|
771
775
|
};
|
|
772
776
|
}
|
|
@@ -62,6 +62,15 @@ export declare function bootstrapExternal(ctx: McpContext): Promise<{
|
|
|
62
62
|
clearedTables: number;
|
|
63
63
|
dbCleared: boolean;
|
|
64
64
|
errors: string[];
|
|
65
|
+
trash: {
|
|
66
|
+
folder: string;
|
|
67
|
+
movedItems: number;
|
|
68
|
+
dbSnapshotRows: number;
|
|
69
|
+
} | null;
|
|
70
|
+
purgedTrash: {
|
|
71
|
+
count: number;
|
|
72
|
+
freedBytes: number;
|
|
73
|
+
} | null;
|
|
65
74
|
};
|
|
66
75
|
} | null;
|
|
67
76
|
meta: {
|
|
@@ -115,7 +115,7 @@ export async function bootstrapExternal(ctx) {
|
|
|
115
115
|
session,
|
|
116
116
|
languageExtension: buildLanguageExtension(primaryLang), // §7.1
|
|
117
117
|
languageStats: langStats,
|
|
118
|
-
panoramaResult: snapshot.panorama, // §M1: Phase
|
|
118
|
+
panoramaResult: snapshot.panorama, // §M1: Phase 2.2 全景数据
|
|
119
119
|
localPackageModules, // 本地子包模块信息
|
|
120
120
|
});
|
|
121
121
|
// 附加 warnings
|
|
@@ -133,6 +133,8 @@ export async function bootstrapExternal(ctx) {
|
|
|
133
133
|
clearedTables: cleanupResult.clearedTables.length,
|
|
134
134
|
dbCleared: true,
|
|
135
135
|
errors: cleanupResult.errors,
|
|
136
|
+
trash: cleanupResult.trash ?? null,
|
|
137
|
+
purgedTrash: cleanupResult.purgedTrash ?? null,
|
|
136
138
|
},
|
|
137
139
|
...briefing,
|
|
138
140
|
},
|
|
@@ -223,6 +223,8 @@ export async function bootstrapKnowledge(ctx, args) {
|
|
|
223
223
|
clearedTables: cleanupResult.clearedTables.length,
|
|
224
224
|
dbCleared: true,
|
|
225
225
|
errors: cleanupResult.errors,
|
|
226
|
+
trash: cleanupResult.trash ?? null,
|
|
227
|
+
purgedTrash: cleanupResult.purgedTrash ?? null,
|
|
226
228
|
},
|
|
227
229
|
report,
|
|
228
230
|
targets: targetsSummary ||
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* autosnippet_bootstrap 已迁移到 bootstrap-external.js(外部 Agent 路径)。
|
|
10
10
|
*/
|
|
11
11
|
import { getRequiredFieldsDescription } from '#domain/knowledge/FieldSpec.js';
|
|
12
|
+
import { getDeveloperIdentity } from '#shared/developer-identity.js';
|
|
12
13
|
import { envelope } from '../envelope.js';
|
|
13
14
|
import * as browseHandlers from './browse.js';
|
|
14
15
|
import * as guardHandlers from './guard.js';
|
|
@@ -285,7 +286,7 @@ export async function enhancedSubmitKnowledge(ctx, args) {
|
|
|
285
286
|
skipConsolidation,
|
|
286
287
|
supersedes,
|
|
287
288
|
existingTitles,
|
|
288
|
-
userId:
|
|
289
|
+
userId: getDeveloperIdentity(),
|
|
289
290
|
},
|
|
290
291
|
});
|
|
291
292
|
// ── Step 4: Bootstrap session 追踪 ──
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import Logger from '#infra/logging/Logger.js';
|
|
18
18
|
import { BootstrapEventEmitter } from '#service/bootstrap/BootstrapEventEmitter.js';
|
|
19
|
+
import { getDeveloperIdentity } from '#shared/developer-identity.js';
|
|
19
20
|
import { envelope } from '../envelope.js';
|
|
20
21
|
import { saveDimensionCheckpoint } from './bootstrap/pipeline/checkpoint.js';
|
|
21
22
|
import { BOOTSTRAP_COMPLETE_ACTIONS } from './bootstrap/shared/dimension-text.js';
|
|
@@ -160,7 +161,7 @@ export async function dimensionComplete(ctx, args) {
|
|
|
160
161
|
await knowledgeService.update(recipeId, {
|
|
161
162
|
category: dimensionId,
|
|
162
163
|
tags: newTags,
|
|
163
|
-
}, { userId:
|
|
164
|
+
}, { userId: getDeveloperIdentity() });
|
|
164
165
|
recipesBound++;
|
|
165
166
|
}
|
|
166
167
|
}
|
|
@@ -272,7 +273,7 @@ export async function dimensionComplete(ctx, args) {
|
|
|
272
273
|
if (knowledgeGraphService && keyFindings.length > 0) {
|
|
273
274
|
// 将每个 keyFinding 创建为知识图谱中的实体
|
|
274
275
|
for (const finding of keyFindings) {
|
|
275
|
-
knowledgeGraphService.addEdge(dimensionId, 'dimension', finding.substring(0, 80), 'finding', 'discovered_in', { source: 'external-agent-bootstrap', sessionId: session.id });
|
|
276
|
+
await knowledgeGraphService.addEdge(dimensionId, 'dimension', finding.substring(0, 80), 'finding', 'discovered_in', { source: 'external-agent-bootstrap', sessionId: session.id });
|
|
276
277
|
}
|
|
277
278
|
}
|
|
278
279
|
}
|
|
@@ -350,7 +351,7 @@ export async function dimensionComplete(ctx, args) {
|
|
|
350
351
|
if (panoramaService &&
|
|
351
352
|
typeof panoramaService.rescan === 'function') {
|
|
352
353
|
await panoramaService.rescan();
|
|
353
|
-
const overview = panoramaService.getOverview();
|
|
354
|
+
const overview = await panoramaService.getOverview();
|
|
354
355
|
logger.info(`[DimensionComplete] Panorama refreshed — ${overview.moduleCount} modules, ${overview.gapCount} gaps`);
|
|
355
356
|
}
|
|
356
357
|
}
|
|
@@ -387,7 +388,11 @@ export async function dimensionComplete(ctx, args) {
|
|
|
387
388
|
const db = ctx.container.get?.('database') ?? ctx.container.get?.('db');
|
|
388
389
|
if (db && session.sessionStore) {
|
|
389
390
|
const { PersistentMemory } = await import('#agent/memory/PersistentMemory.js');
|
|
390
|
-
const
|
|
391
|
+
const { MemoryEmbeddingStore } = await import('#agent/memory/MemoryEmbeddingStore.js');
|
|
392
|
+
const semanticMemory = new PersistentMemory(db, {
|
|
393
|
+
logger,
|
|
394
|
+
embeddingStore: new MemoryEmbeddingStore(projectRoot),
|
|
395
|
+
});
|
|
391
396
|
const consolidator = new EpisodicConsolidator(semanticMemory, { logger });
|
|
392
397
|
const result = await consolidator.consolidate(session.sessionStore, {
|
|
393
398
|
bootstrapSession: session.id,
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import type { ServiceContainer } from '#inject/ServiceContainer.js';
|
|
16
16
|
import type { EvolveInput } from '#shared/schemas/mcp-tools.js';
|
|
17
17
|
/** MCP handler context */
|
|
18
|
+
/** MCP handler context */
|
|
18
19
|
interface McpContext {
|
|
19
20
|
container: ServiceContainer;
|
|
20
21
|
logger: {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module handlers/evolve-external
|
|
14
14
|
*/
|
|
15
|
+
import { getDeveloperIdentity } from '#shared/developer-identity.js';
|
|
15
16
|
import { envelope } from '../envelope.js';
|
|
16
17
|
// ── 主入口 ─────────────────────────────────────────────────
|
|
17
18
|
export async function evolveExternal(ctx, args) {
|
|
@@ -45,15 +46,12 @@ export async function evolveExternal(ctx, args) {
|
|
|
45
46
|
const proposalRepo = ctx.container.get('proposalRepository');
|
|
46
47
|
const knowledgeService = ctx.container.get('knowledgeService');
|
|
47
48
|
const supervisor = ctx.container.get('lifecycleSupervisor');
|
|
48
|
-
const
|
|
49
|
-
const rawDb = dbConn?.db ?? null;
|
|
49
|
+
const knowledgeRepo = ctx.container.get('knowledgeRepository');
|
|
50
50
|
for (const decision of decisions) {
|
|
51
51
|
try {
|
|
52
52
|
// O4: Recipe 存在性前置检查
|
|
53
|
-
if (
|
|
54
|
-
const exists =
|
|
55
|
-
.prepare('SELECT 1 FROM knowledge_entries WHERE id = ?')
|
|
56
|
-
.get(decision.recipeId);
|
|
53
|
+
if (knowledgeRepo) {
|
|
54
|
+
const exists = await knowledgeRepo.findById(decision.recipeId);
|
|
57
55
|
if (!exists) {
|
|
58
56
|
result.errors.push({ recipeId: decision.recipeId, error: 'Recipe not found' });
|
|
59
57
|
result.processed++;
|
|
@@ -110,7 +108,7 @@ export async function evolveExternal(ctx, args) {
|
|
|
110
108
|
// O1: 优先通过 RecipeLifecycleSupervisor 执行,回退到 KnowledgeService
|
|
111
109
|
const reason = decision.reason || 'IDE Agent confirmed deprecation';
|
|
112
110
|
if (supervisor) {
|
|
113
|
-
const transResult = supervisor.transition({
|
|
111
|
+
const transResult = await supervisor.transition({
|
|
114
112
|
recipeId: decision.recipeId,
|
|
115
113
|
targetState: 'deprecated',
|
|
116
114
|
trigger: 'manual-deprecation',
|
|
@@ -121,7 +119,7 @@ export async function evolveExternal(ctx, args) {
|
|
|
121
119
|
// Supervisor 拒绝(可能状态不允许直接转 deprecated),回退到 KnowledgeService
|
|
122
120
|
if (knowledgeService) {
|
|
123
121
|
await knowledgeService.deprecate(decision.recipeId, reason, {
|
|
124
|
-
userId:
|
|
122
|
+
userId: getDeveloperIdentity(),
|
|
125
123
|
});
|
|
126
124
|
}
|
|
127
125
|
else {
|
|
@@ -135,7 +133,9 @@ export async function evolveExternal(ctx, args) {
|
|
|
135
133
|
}
|
|
136
134
|
else if (knowledgeService) {
|
|
137
135
|
// P3: 添加 await
|
|
138
|
-
await knowledgeService.deprecate(decision.recipeId, reason, {
|
|
136
|
+
await knowledgeService.deprecate(decision.recipeId, reason, {
|
|
137
|
+
userId: getDeveloperIdentity(),
|
|
138
|
+
});
|
|
139
139
|
}
|
|
140
140
|
else {
|
|
141
141
|
result.errors.push({
|
|
@@ -164,17 +164,17 @@ export async function evolveExternal(ctx, args) {
|
|
|
164
164
|
break;
|
|
165
165
|
}
|
|
166
166
|
case 'skip': {
|
|
167
|
-
if (decision.skipReason === 'still_valid' &&
|
|
167
|
+
if (decision.skipReason === 'still_valid' && knowledgeRepo) {
|
|
168
168
|
// P4: 更新 stats.lastVerifiedAt 而非 updated_at
|
|
169
169
|
try {
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
.
|
|
177
|
-
|
|
170
|
+
const entry = await knowledgeRepo.findById(decision.recipeId);
|
|
171
|
+
if (entry) {
|
|
172
|
+
const stats = (typeof entry.stats === 'object'
|
|
173
|
+
? entry.stats
|
|
174
|
+
: {});
|
|
175
|
+
stats.lastVerifiedAt = Date.now();
|
|
176
|
+
await knowledgeRepo.updateStats(decision.recipeId, stats);
|
|
177
|
+
}
|
|
178
178
|
result.refreshed++;
|
|
179
179
|
}
|
|
180
180
|
catch {
|
|
@@ -211,7 +211,7 @@ export async function guardReview(ctx, args) {
|
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
// 2. 预加载 rule recipe 缓存
|
|
214
|
-
const recipeMap = _loadRuleRecipes(ctx);
|
|
214
|
+
const recipeMap = await _loadRuleRecipes(ctx);
|
|
215
215
|
// 3. 创建引擎,注入 Enhancement Pack
|
|
216
216
|
const engine = _getOrCreateEngine(ctx, GuardCheckEngine);
|
|
217
217
|
await _injectEnhancementGuardRules(engine, ctx);
|
|
@@ -355,24 +355,17 @@ export async function guardReview(ctx, args) {
|
|
|
355
355
|
* 预加载所有 rule 类型 recipe 的修复字段
|
|
356
356
|
* 构建 guardId → recipe 映射
|
|
357
357
|
*/
|
|
358
|
-
function _loadRuleRecipes(ctx) {
|
|
358
|
+
async function _loadRuleRecipes(ctx) {
|
|
359
359
|
const map = new Map();
|
|
360
360
|
try {
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const rows = db
|
|
365
|
-
.prepare(`
|
|
366
|
-
SELECT id, title, doClause, dontClause, coreCode, constraints
|
|
367
|
-
FROM knowledge_entries
|
|
368
|
-
WHERE (kind = 'rule' OR knowledgeType = 'boundary-constraint')
|
|
369
|
-
AND lifecycle = 'active'
|
|
370
|
-
`)
|
|
371
|
-
.all();
|
|
372
|
-
for (const row of rows) {
|
|
361
|
+
const knowledgeRepo = ctx.container.get('knowledgeRepository');
|
|
362
|
+
const entries = await knowledgeRepo.findActiveGuardRecipes();
|
|
363
|
+
for (const row of entries) {
|
|
373
364
|
try {
|
|
374
|
-
const constraints =
|
|
375
|
-
|
|
365
|
+
const constraints = typeof row.constraints === 'object' && row.constraints
|
|
366
|
+
? row.constraints
|
|
367
|
+
: JSON.parse(row.constraints || '{}');
|
|
368
|
+
const guards = (constraints.guards || []);
|
|
376
369
|
for (const g of guards) {
|
|
377
370
|
if (g.id) {
|
|
378
371
|
map.set(g.id, {
|
|
@@ -675,8 +668,7 @@ export async function guardReverseAudit(ctx, args) {
|
|
|
675
668
|
reverseGuard = ctx.container.get('reverseGuard');
|
|
676
669
|
}
|
|
677
670
|
catch {
|
|
678
|
-
|
|
679
|
-
reverseGuard = new ReverseGuard(db.getDb());
|
|
671
|
+
reverseGuard = new ReverseGuard(ctx.container.get('knowledgeRepository'), ctx.container.get('codeEntityRepository'), ctx.container.get('recipeSourceRefRepository'));
|
|
680
672
|
}
|
|
681
673
|
const maxFiles = args.maxFiles || 200;
|
|
682
674
|
const projectFiles = await collectSourceFilesWithContent(projectRoot, { maxFiles });
|
|
@@ -717,8 +709,7 @@ export async function guardCoverageMatrix(ctx, _args) {
|
|
|
717
709
|
analyzer = ctx.container.get('coverageAnalyzer');
|
|
718
710
|
}
|
|
719
711
|
catch {
|
|
720
|
-
|
|
721
|
-
analyzer = new CoverageAnalyzer(db.getDb());
|
|
712
|
+
analyzer = new CoverageAnalyzer(ctx.container.get('knowledgeRepository'), ctx.container.get('guardViolationRepository'));
|
|
722
713
|
}
|
|
723
714
|
// 构建 moduleFiles 映射 — 从 Panorama 或目录结构推断
|
|
724
715
|
const moduleFiles = await _buildModuleFiles(ctx, projectRoot);
|
|
@@ -798,11 +789,11 @@ async function _buildModuleFiles(ctx, projectRoot) {
|
|
|
798
789
|
const moduleFiles = new Map();
|
|
799
790
|
try {
|
|
800
791
|
const panorama = ctx.container.get('panoramaService');
|
|
801
|
-
const
|
|
802
|
-
if (
|
|
803
|
-
for (const mod of
|
|
792
|
+
const result = await panorama.getResult();
|
|
793
|
+
if (result?.modules) {
|
|
794
|
+
for (const [name, mod] of result.modules) {
|
|
804
795
|
if (mod.files?.length > 0) {
|
|
805
|
-
moduleFiles.set(
|
|
796
|
+
moduleFiles.set(name, mod.files);
|
|
806
797
|
}
|
|
807
798
|
}
|
|
808
799
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* submitKnowledge, submitKnowledgeBatch, knowledgeLifecycle
|
|
4
4
|
*/
|
|
5
5
|
import { UnifiedValidator } from '#domain/knowledge/UnifiedValidator.js';
|
|
6
|
+
import { getDeveloperIdentity } from '#shared/developer-identity.js';
|
|
6
7
|
import { resolveProjectRoot } from '#shared/resolveProjectRoot.js';
|
|
7
8
|
import { envelope } from '../envelope.js';
|
|
8
9
|
// ─── 限流 ──────────────────────────────────────────────────
|
|
@@ -69,7 +70,7 @@ export async function submitKnowledge(ctx, args) {
|
|
|
69
70
|
const service = ctx.container.get('knowledgeService');
|
|
70
71
|
// V3 字段增强
|
|
71
72
|
const enrichedData = _enrichToV3(args, ctx.container);
|
|
72
|
-
const entry = await service.create(enrichedData, { userId:
|
|
73
|
+
const entry = await service.create(enrichedData, { userId: getDeveloperIdentity() });
|
|
73
74
|
// ── QualityScorer 自动评分(R9: create 后置执行)──
|
|
74
75
|
try {
|
|
75
76
|
await service.updateQuality(entry.id, { userId: 'mcp' });
|
|
@@ -193,10 +194,10 @@ export async function submitKnowledgeBatch(ctx, args) {
|
|
|
193
194
|
}
|
|
194
195
|
try {
|
|
195
196
|
const itemData = _enrichToV3({ ...items[i], source }, ctx.container);
|
|
196
|
-
const entry = await service.create(itemData, { userId:
|
|
197
|
+
const entry = await service.create(itemData, { userId: getDeveloperIdentity() });
|
|
197
198
|
// ── QualityScorer 自动评分(R9: create 后置执行)──
|
|
198
199
|
try {
|
|
199
|
-
await service.updateQuality(entry.id, { userId:
|
|
200
|
+
await service.updateQuality(entry.id, { userId: getDeveloperIdentity() });
|
|
200
201
|
}
|
|
201
202
|
catch {
|
|
202
203
|
/* best effort — 不阻塞批量提交 */
|
|
@@ -269,7 +270,7 @@ export async function knowledgeLifecycle(ctx, args) {
|
|
|
269
270
|
throw new Error(`[PERMISSION_DENIED] 外部 Agent 不允许执行 "${action}" 操作,仅支持: reactivate。发布、废弃等操作请在 Dashboard 中完成。提交新知识请使用 autosnippet_submit_knowledge 工具。`);
|
|
270
271
|
}
|
|
271
272
|
const service = ctx.container.get('knowledgeService');
|
|
272
|
-
const context = { userId:
|
|
273
|
+
const context = { userId: getDeveloperIdentity() };
|
|
273
274
|
const entry = await service.reactivate(id, context);
|
|
274
275
|
return envelope({
|
|
275
276
|
success: true,
|
|
@@ -31,7 +31,7 @@ export async function panoramaHandler(ctx, args) {
|
|
|
31
31
|
await panoramaService.ensureData();
|
|
32
32
|
switch (op) {
|
|
33
33
|
case 'overview': {
|
|
34
|
-
const overview = panoramaService.getOverview();
|
|
34
|
+
const overview = await panoramaService.getOverview();
|
|
35
35
|
return envelope({
|
|
36
36
|
success: true,
|
|
37
37
|
data: overview,
|
|
@@ -47,7 +47,7 @@ export async function panoramaHandler(ctx, args) {
|
|
|
47
47
|
meta: { tool: 'autosnippet_panorama' },
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
const detail = panoramaService.getModule(moduleName);
|
|
50
|
+
const detail = await panoramaService.getModule(moduleName);
|
|
51
51
|
if (!detail) {
|
|
52
52
|
return envelope({
|
|
53
53
|
success: false,
|
|
@@ -62,7 +62,7 @@ export async function panoramaHandler(ctx, args) {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
case 'gaps': {
|
|
65
|
-
const gaps = panoramaService.getGaps();
|
|
65
|
+
const gaps = await panoramaService.getGaps();
|
|
66
66
|
return envelope({
|
|
67
67
|
success: true,
|
|
68
68
|
data: { gaps },
|
|
@@ -70,7 +70,7 @@ export async function panoramaHandler(ctx, args) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
case 'health': {
|
|
73
|
-
const health = panoramaService.getHealth();
|
|
73
|
+
const health = await panoramaService.getHealth();
|
|
74
74
|
return envelope({
|
|
75
75
|
success: true,
|
|
76
76
|
data: health,
|
|
@@ -94,7 +94,7 @@ async function handleGovernanceOps(ctx, op) {
|
|
|
94
94
|
meta: { tool: 'autosnippet_panorama' },
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
|
-
const report = metabolism.runFullCycle();
|
|
97
|
+
const report = await metabolism.runFullCycle();
|
|
98
98
|
return envelope({
|
|
99
99
|
success: true,
|
|
100
100
|
data: report,
|
|
@@ -110,7 +110,7 @@ async function handleGovernanceOps(ctx, op) {
|
|
|
110
110
|
meta: { tool: 'autosnippet_panorama' },
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
const results = decayDetector.scanAll();
|
|
113
|
+
const results = await decayDetector.scanAll();
|
|
114
114
|
return envelope({
|
|
115
115
|
success: true,
|
|
116
116
|
data: { results },
|
|
@@ -126,8 +126,8 @@ async function handleGovernanceOps(ctx, op) {
|
|
|
126
126
|
meta: { tool: 'autosnippet_panorama' },
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
const checkResult = stagingManager.checkAndPromote();
|
|
130
|
-
const currentStaging = stagingManager.listStaging();
|
|
129
|
+
const checkResult = await stagingManager.checkAndPromote();
|
|
130
|
+
const currentStaging = await stagingManager.listStaging();
|
|
131
131
|
return envelope({
|
|
132
132
|
success: true,
|
|
133
133
|
data: { checkResult, currentStaging },
|
|
@@ -143,7 +143,7 @@ async function handleGovernanceOps(ctx, op) {
|
|
|
143
143
|
meta: { tool: 'autosnippet_panorama' },
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
const suggestions = suggester.analyzeAll();
|
|
146
|
+
const suggestions = await suggester.analyzeAll();
|
|
147
147
|
return envelope({
|
|
148
148
|
success: true,
|
|
149
149
|
data: { suggestions },
|
|
@@ -65,10 +65,7 @@ export async function rescanExternal(ctx, args) {
|
|
|
65
65
|
? ctx.container.get('knowledgeSyncService')
|
|
66
66
|
: null;
|
|
67
67
|
if (syncService) {
|
|
68
|
-
const
|
|
69
|
-
? db.getDb()
|
|
70
|
-
: db;
|
|
71
|
-
const syncReport = syncService.sync(rawDb, {
|
|
68
|
+
const syncReport = syncService.sync(db, {
|
|
72
69
|
force: true,
|
|
73
70
|
});
|
|
74
71
|
ctx.logger.info('[Rescan] KnowledgeSyncService sync complete', {
|
|
@@ -117,7 +114,11 @@ export async function rescanExternal(ctx, args) {
|
|
|
117
114
|
// Step 4: Recipe 证据验证 + 快速衰退
|
|
118
115
|
// ═══════════════════════════════════════════════════════════
|
|
119
116
|
const auditor = new RecipeRelevanceAuditor({
|
|
120
|
-
|
|
117
|
+
knowledgeRepo: ctx.container.get('knowledgeRepository'),
|
|
118
|
+
proposalRepo: ctx.container.singletons
|
|
119
|
+
?.proposalRepository
|
|
120
|
+
? ctx.container.get('proposalRepository')
|
|
121
|
+
: undefined,
|
|
121
122
|
logger: ctx.logger,
|
|
122
123
|
});
|
|
123
124
|
const codeEntities = extractCodeEntities(astProjectSummary);
|
|
@@ -132,7 +133,7 @@ export async function rescanExternal(ctx, args) {
|
|
|
132
133
|
// ═══════════════════════════════════════════════════════════
|
|
133
134
|
// 按需过滤维度
|
|
134
135
|
const dimensions = args.dimensions?.length
|
|
135
|
-
? allDimensions.filter((d) => args.dimensions
|
|
136
|
+
? allDimensions.filter((d) => args.dimensions?.includes(d.id))
|
|
136
137
|
: allDimensions;
|
|
137
138
|
// 创建 Session
|
|
138
139
|
const sessionManager = getOrCreateSessionManager(ctx.container);
|
|
@@ -71,10 +71,7 @@ export async function rescanInternal(ctx, args) {
|
|
|
71
71
|
/* not registered */
|
|
72
72
|
}
|
|
73
73
|
if (syncService) {
|
|
74
|
-
const
|
|
75
|
-
? db.getDb()
|
|
76
|
-
: db;
|
|
77
|
-
const syncReport = syncService.sync(rawDb, {
|
|
74
|
+
const syncReport = syncService.sync(db, {
|
|
78
75
|
force: true,
|
|
79
76
|
});
|
|
80
77
|
ctx.logger.info('[Rescan-Internal] KnowledgeSyncService sync complete', {
|
|
@@ -119,7 +116,14 @@ export async function rescanInternal(ctx, args) {
|
|
|
119
116
|
// ═══════════════════════════════════════════════════════════
|
|
120
117
|
// Step 4: Recipe 证据验证 + 快速衰退
|
|
121
118
|
// ═══════════════════════════════════════════════════════════
|
|
122
|
-
const auditor = new RecipeRelevanceAuditor({
|
|
119
|
+
const auditor = new RecipeRelevanceAuditor({
|
|
120
|
+
knowledgeRepo: ctx.container.get('knowledgeRepository'),
|
|
121
|
+
proposalRepo: ctx.container.singletons
|
|
122
|
+
?.proposalRepository
|
|
123
|
+
? ctx.container.get('proposalRepository')
|
|
124
|
+
: undefined,
|
|
125
|
+
logger: ctx.logger,
|
|
126
|
+
});
|
|
123
127
|
const codeEntities = extractCodeEntities(astProjectSummary);
|
|
124
128
|
const dependencyEdges = extractDependencyEdges(depGraphData);
|
|
125
129
|
const auditSummary = await auditor.audit(recipeSnapshot.entries, {
|
|
@@ -30,7 +30,9 @@ function getSearchEngine(ctx) {
|
|
|
30
30
|
async function getFallbackEngine(ctx) {
|
|
31
31
|
const { SearchEngine } = await import('#service/search/SearchEngine.js');
|
|
32
32
|
const db = ctx.container.get('database');
|
|
33
|
-
|
|
33
|
+
const knowledgeRepo = ctx.container.get('knowledgeRepository');
|
|
34
|
+
const sourceRefRepo = ctx.container.get('recipeSourceRefRepository');
|
|
35
|
+
return new SearchEngine(db, { knowledgeRepo, sourceRefRepo });
|
|
34
36
|
}
|
|
35
37
|
/** 根据 kind 参数过滤 items */
|
|
36
38
|
function filterByKind(items, kind) {
|
|
@@ -648,11 +648,11 @@ export async function suggestSkills(ctx) {
|
|
|
648
648
|
}
|
|
649
649
|
// ── Fallback: 直接使用 SkillAdvisor ──
|
|
650
650
|
const { SkillAdvisor } = await import('#service/skills/SkillAdvisor.js');
|
|
651
|
-
const dbConn = ctx?.container?.get?.('database') || null;
|
|
652
|
-
const database = dbConn?.getDb?.() || dbConn || null;
|
|
653
651
|
const projectRoot = resolveProjectRoot(ctx?.container);
|
|
654
|
-
const
|
|
655
|
-
const
|
|
652
|
+
const knowledgeRepo = ctx?.container?.get?.('knowledgeRepository') || null;
|
|
653
|
+
const auditRepo = ctx?.container?.get?.('auditRepository') || null;
|
|
654
|
+
const advisor = new SkillAdvisor(projectRoot, { knowledgeRepo, auditRepo });
|
|
655
|
+
const result = await advisor.suggest();
|
|
656
656
|
return JSON.stringify({
|
|
657
657
|
success: true,
|
|
658
658
|
data: result,
|