autosnippet 3.3.5 → 3.3.7
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-FHns2ypa.js +1 -0
- package/dashboard/dist/assets/index-BRJv5Y3r.js +135 -0
- package/dashboard/dist/assets/index-DzoB7kxK.css +1 -0
- package/dashboard/dist/index.html +3 -3
- package/dist/bin/api-server.js +1 -0
- package/dist/bin/cli.d.ts +1 -0
- package/dist/bin/cli.js +137 -9
- package/dist/lib/agent/AgentFactory.d.ts +0 -17
- package/dist/lib/agent/AgentFactory.js +1 -25
- package/dist/lib/agent/AgentRuntime.d.ts +2 -2
- package/dist/lib/agent/AgentRuntime.js +26 -18
- package/dist/lib/agent/capabilities.d.ts +11 -0
- package/dist/lib/agent/capabilities.js +29 -5
- package/dist/lib/agent/context/ExplorationTracker.js +10 -1
- package/dist/lib/agent/context/exploration/ExplorationStrategies.d.ts +2 -0
- package/dist/lib/agent/context/exploration/ExplorationStrategies.js +2 -2
- package/dist/lib/agent/domain/ChatAgentTasks.js +4 -0
- package/dist/lib/agent/domain/insight-analyst.d.ts +47 -3
- package/dist/lib/agent/domain/insight-analyst.js +111 -11
- package/dist/lib/agent/domain/insight-evolver.d.ts +69 -0
- package/dist/lib/agent/domain/insight-evolver.js +230 -0
- package/dist/lib/agent/domain/insight-gate.d.ts +42 -0
- package/dist/lib/agent/domain/insight-gate.js +41 -0
- package/dist/lib/agent/domain/insight-producer.d.ts +27 -2
- package/dist/lib/agent/domain/insight-producer.js +60 -5
- package/dist/lib/agent/domain/scan-prompts.js +10 -7
- package/dist/lib/agent/forced-summary.js +7 -2
- package/dist/lib/agent/memory/ActiveContext.d.ts +2 -28
- package/dist/lib/agent/memory/MemoryCoordinator.d.ts +2 -2
- package/dist/lib/agent/memory/SessionStore.d.ts +6 -12
- package/dist/lib/agent/memory/SessionStore.js +9 -15
- package/dist/lib/agent/memory/memory-flush-contract.d.ts +49 -0
- package/dist/lib/agent/memory/memory-flush-contract.js +16 -0
- package/dist/lib/agent/memory/session-store-schema.d.ts +20 -0
- package/dist/lib/agent/memory/session-store-schema.js +41 -0
- package/dist/lib/agent/presets.d.ts +89 -1
- package/dist/lib/agent/presets.js +53 -5
- package/dist/lib/agent/tools/_shared.d.ts +7 -15
- package/dist/lib/agent/tools/_shared.js +20 -21
- package/dist/lib/agent/tools/composite.d.ts +25 -22
- package/dist/lib/agent/tools/composite.js +108 -109
- package/dist/lib/agent/tools/evolution-tools.d.ts +145 -0
- package/dist/lib/agent/tools/evolution-tools.js +161 -0
- package/dist/lib/agent/tools/index.d.ts +163 -92
- package/dist/lib/agent/tools/index.js +9 -1
- package/dist/lib/agent/tools/lifecycle.d.ts +7 -1
- package/dist/lib/agent/tools/lifecycle.js +59 -75
- package/dist/lib/cli/AiScanService.js +5 -5
- package/dist/lib/cli/KnowledgeSyncService.js +1 -1
- package/dist/lib/core/AstAnalyzer.d.ts +1 -0
- 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 +30 -0
- package/dist/lib/core/discovery/CustomConfigDiscoverer.js +1305 -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/{service/bootstrap/DimensionCopyRegistry.d.ts → domain/dimension/DimensionCopy.d.ts} +2 -2
- package/dist/lib/{service/bootstrap/DimensionCopyRegistry.js → domain/dimension/DimensionCopy.js} +22 -72
- package/dist/lib/domain/dimension/DimensionRegistry.d.ts +54 -0
- package/dist/lib/domain/dimension/DimensionRegistry.js +620 -0
- package/dist/lib/domain/dimension/DimensionSop.d.ts +55 -0
- package/dist/lib/domain/dimension/DimensionSop.js +1604 -0
- package/dist/lib/domain/dimension/UnifiedDimension.d.ts +61 -0
- package/dist/lib/domain/dimension/UnifiedDimension.js +53 -0
- package/dist/lib/domain/dimension/index.d.ts +10 -0
- package/dist/lib/domain/dimension/index.js +9 -0
- package/dist/lib/domain/knowledge/FieldSpec.d.ts +1 -1
- package/dist/lib/domain/knowledge/FieldSpec.js +29 -16
- package/dist/lib/domain/knowledge/KnowledgeEntry.d.ts +40 -112
- package/dist/lib/domain/knowledge/KnowledgeEntry.js +44 -9
- package/dist/lib/domain/knowledge/KnowledgeRepository.d.ts +1 -0
- package/dist/lib/domain/knowledge/KnowledgeRepository.js +3 -0
- package/dist/lib/domain/knowledge/Lifecycle.js +1 -1
- package/dist/lib/domain/knowledge/StyleGuide.d.ts +1 -1
- package/dist/lib/domain/knowledge/StyleGuide.js +1 -1
- package/dist/lib/domain/knowledge/UnifiedValidator.js +15 -0
- 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/McpServer.js +4 -0
- package/dist/lib/external/mcp/handlers/TargetClassifier.d.ts +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/BootstrapSession.d.ts +8 -16
- package/dist/lib/external/mcp/handlers/bootstrap/BootstrapSession.js +10 -10
- package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.d.ts +7 -0
- package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.js +20 -0
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.d.ts +52 -132
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +204 -17
- package/dist/lib/external/mcp/handlers/bootstrap/base-dimensions.d.ts +11 -75
- package/dist/lib/external/mcp/handlers/bootstrap/base-dimensions.js +40 -191
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.d.ts +13 -78
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.js +30 -52
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-context.d.ts +0 -1
- 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.d.ts +99 -12
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +188 -169
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/tier-scheduler.js +7 -17
- package/dist/lib/external/mcp/handlers/bootstrap/refine.js +8 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/async-fill-helpers.d.ts +46 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/async-fill-helpers.js +58 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/audit-helpers.d.ts +25 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/audit-helpers.js +47 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.d.ts +50 -12
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +30 -10
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-text.js +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/shared/handler-types.d.ts +24 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/handler-types.js +14 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/panorama-utils.d.ts +14 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/panorama-utils.js +48 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/session-helpers.d.ts +21 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/session-helpers.js +45 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/skill-generator.d.ts +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/shared/target-file-map.d.ts +27 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/target-file-map.js +44 -0
- package/dist/lib/external/mcp/handlers/bootstrap-external.d.ts +23 -10
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +41 -51
- package/dist/lib/external/mcp/handlers/bootstrap-internal.d.ts +2 -0
- package/dist/lib/external/mcp/handlers/bootstrap-internal.js +117 -82
- package/dist/lib/external/mcp/handlers/consolidated.d.ts +4 -4
- package/dist/lib/external/mcp/handlers/consolidated.js +108 -332
- package/dist/lib/external/mcp/handlers/dimension-complete-external.js +71 -2
- package/dist/lib/external/mcp/handlers/evolve-external.d.ts +54 -0
- package/dist/lib/external/mcp/handlers/evolve-external.js +229 -0
- package/dist/lib/external/mcp/handlers/knowledge.js +30 -5
- package/dist/lib/external/mcp/handlers/rescan-external.d.ts +76 -0
- package/dist/lib/external/mcp/handlers/rescan-external.js +335 -0
- package/dist/lib/external/mcp/handlers/rescan-internal.d.ts +120 -0
- package/dist/lib/external/mcp/handlers/rescan-internal.js +359 -0
- package/dist/lib/external/mcp/handlers/search.d.ts +6 -5
- package/dist/lib/external/mcp/handlers/search.js +6 -5
- package/dist/lib/external/mcp/handlers/types.d.ts +2 -1
- package/dist/lib/external/mcp/handlers/wiki-external.js +2 -2
- package/dist/lib/external/mcp/tools.d.ts +8 -18
- package/dist/lib/external/mcp/tools.js +58 -2
- package/dist/lib/http/routes/ai.js +111 -30
- package/dist/lib/http/routes/candidates.js +11 -4
- package/dist/lib/http/routes/commands.js +10 -1
- package/dist/lib/http/routes/health.js +11 -0
- package/dist/lib/http/routes/knowledge.js +122 -1
- package/dist/lib/http/routes/modules.js +52 -3
- package/dist/lib/http/routes/panorama.js +16 -4
- package/dist/lib/http/routes/recipes.js +7 -0
- package/dist/lib/http/utils/routeHelpers.js +2 -1
- package/dist/lib/infrastructure/cache/CacheCoordinator.d.ts +41 -0
- package/dist/lib/infrastructure/cache/CacheCoordinator.js +105 -0
- package/dist/lib/infrastructure/database/migrations/006_lifecycle_transition_events.d.ts +7 -0
- package/dist/lib/infrastructure/database/migrations/006_lifecycle_transition_events.js +28 -0
- package/dist/lib/infrastructure/vector/HnswVectorAdapter.js +1 -1
- package/dist/lib/injection/ServiceContainer.d.ts +6 -5
- package/dist/lib/injection/ServiceContainer.js +64 -25
- package/dist/lib/injection/ServiceMap.d.ts +10 -1
- package/dist/lib/injection/modules/AiModule.d.ts +6 -9
- package/dist/lib/injection/modules/AiModule.js +82 -39
- package/dist/lib/injection/modules/KnowledgeModule.js +15 -1
- package/dist/lib/injection/modules/PanoramaModule.js +1 -1
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.d.ts +4 -0
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.js +16 -1
- package/dist/lib/service/bootstrap/BootstrapEventEmitter.d.ts +3 -2
- package/dist/lib/service/bootstrap/BootstrapEventEmitter.js +1 -1
- package/dist/lib/service/bootstrap/DeliveryVerifier.d.ts +51 -0
- package/dist/lib/service/bootstrap/DeliveryVerifier.js +163 -0
- package/dist/lib/service/bootstrap/UiStartupTasks.d.ts +5 -0
- package/dist/lib/service/bootstrap/UiStartupTasks.js +20 -0
- package/dist/lib/service/bootstrap/bootstrap-event-types.d.ts +54 -0
- package/dist/lib/service/bootstrap/bootstrap-event-types.js +10 -0
- package/dist/lib/service/cleanup/CleanupService.d.ts +132 -0
- package/dist/lib/service/cleanup/CleanupService.js +571 -0
- package/dist/lib/service/delivery/AgentInstructionsGenerator.js +39 -43
- package/dist/lib/service/delivery/FileProtection.d.ts +20 -0
- package/dist/lib/service/delivery/FileProtection.js +54 -0
- package/dist/lib/service/delivery/SkillsSyncer.js +16 -21
- package/dist/lib/service/evolution/ContentPatcher.d.ts +44 -0
- package/dist/lib/service/evolution/ContentPatcher.js +310 -0
- package/dist/lib/service/evolution/ProposalExecutor.d.ts +4 -0
- package/dist/lib/service/evolution/ProposalExecutor.js +77 -13
- package/dist/lib/service/evolution/RecipeLifecycleSupervisor.d.ts +64 -0
- package/dist/lib/service/evolution/RecipeLifecycleSupervisor.js +458 -0
- package/dist/lib/service/evolution/RecipeRelevanceAuditor.d.ts +89 -0
- package/dist/lib/service/evolution/RecipeRelevanceAuditor.js +492 -0
- package/dist/lib/service/evolution/createSupersedeProposal.d.ts +44 -0
- package/dist/lib/service/evolution/createSupersedeProposal.js +81 -0
- package/dist/lib/service/guard/ComplianceReporter.d.ts +4 -0
- package/dist/lib/service/guard/ComplianceReporter.js +51 -0
- package/dist/lib/service/guard/GuardCheckEngine.js +5 -4
- package/dist/lib/service/knowledge/CodeEntityGraph.d.ts +6 -0
- package/dist/lib/service/knowledge/CodeEntityGraph.js +16 -0
- package/dist/lib/service/knowledge/ConfidenceRouter.js +1 -1
- package/dist/lib/service/knowledge/KnowledgeService.d.ts +11 -1
- package/dist/lib/service/knowledge/KnowledgeService.js +67 -14
- package/dist/lib/service/knowledge/RecipeProductionGateway.d.ts +225 -0
- package/dist/lib/service/knowledge/RecipeProductionGateway.js +384 -0
- package/dist/lib/service/module/ModuleService.js +10 -19
- package/dist/lib/service/panorama/CouplingAnalyzer.d.ts +10 -1
- package/dist/lib/service/panorama/CouplingAnalyzer.js +44 -2
- package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +4 -3
- package/dist/lib/service/panorama/DimensionAnalyzer.js +40 -151
- 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 +9 -0
- package/dist/lib/service/panorama/ModuleDiscoverer.js +58 -2
- package/dist/lib/service/panorama/PanoramaAggregator.d.ts +6 -2
- package/dist/lib/service/panorama/PanoramaAggregator.js +84 -6
- package/dist/lib/service/panorama/PanoramaScanner.js +28 -0
- package/dist/lib/service/panorama/PanoramaService.js +10 -5
- package/dist/lib/service/panorama/PanoramaTypes.d.ts +38 -0
- package/dist/lib/service/panorama/RoleRefiner.d.ts +2 -0
- package/dist/lib/service/panorama/RoleRefiner.js +41 -0
- package/dist/lib/service/panorama/TechStackProfiler.d.ts +13 -0
- package/dist/lib/service/panorama/TechStackProfiler.js +191 -0
- package/dist/lib/service/search/BM25Scorer.d.ts +2 -2
- package/dist/lib/service/search/SearchEngine.d.ts +11 -10
- package/dist/lib/service/search/SearchEngine.js +38 -36
- package/dist/lib/service/search/SearchTypes.d.ts +14 -8
- package/dist/lib/service/search/SearchTypes.js +1 -1
- package/dist/lib/service/search/tokenizer.d.ts +1 -1
- package/dist/lib/service/search/tokenizer.js +2 -2
- package/dist/lib/service/skills/SignalCollector.d.ts +1 -0
- package/dist/lib/service/skills/SignalCollector.js +6 -5
- package/dist/lib/service/vector/ContextualEnricher.d.ts +1 -0
- package/dist/lib/service/vector/ContextualEnricher.js +4 -0
- package/dist/lib/shared/LanguageService.js +3 -0
- package/dist/lib/shared/developer-identity.d.ts +18 -0
- package/dist/lib/shared/developer-identity.js +62 -0
- package/dist/lib/shared/schemas/common.d.ts +4 -4
- package/dist/lib/shared/schemas/http-requests.d.ts +20 -18
- package/dist/lib/shared/schemas/http-requests.js +17 -6
- package/dist/lib/shared/schemas/mcp-tools.d.ts +32 -2
- package/dist/lib/shared/schemas/mcp-tools.js +38 -0
- package/dist/lib/types/evolution.d.ts +135 -0
- package/dist/lib/types/evolution.js +6 -0
- package/dist/lib/types/graph-shared.d.ts +25 -0
- package/dist/lib/types/graph-shared.js +7 -0
- package/dist/lib/types/knowledge-wire.d.ts +132 -0
- package/dist/lib/types/knowledge-wire.js +7 -0
- package/dist/lib/types/project-snapshot-builder.d.ts +19 -0
- package/dist/lib/types/project-snapshot-builder.js +189 -0
- package/dist/lib/types/project-snapshot.d.ts +399 -0
- package/dist/lib/types/project-snapshot.js +17 -0
- package/dist/lib/types/search-wire.d.ts +46 -0
- package/dist/lib/types/search-wire.js +7 -0
- package/dist/lib/types/snapshot-views.d.ts +58 -0
- package/dist/lib/types/snapshot-views.js +103 -0
- package/package.json +1 -1
- package/skills/autosnippet-recipes/SKILL.md +1 -1
- package/templates/instructions/agent-static.md +2 -0
- package/templates/instructions/conventions.md +3 -1
- package/templates/recipes-setup/README.md +2 -2
- package/dashboard/dist/assets/icons-BJ2mUBi8.js +0 -1
- package/dashboard/dist/assets/index-B659K9t5.js +0 -128
- package/dashboard/dist/assets/index-NCm40PMD.css +0 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.d.ts +0 -169
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.js +0 -727
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.d.ts +0 -370
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.js +0 -821
|
@@ -23,26 +23,26 @@ import { MemoryCoordinator } from '#agent/memory/MemoryCoordinator.js';
|
|
|
23
23
|
import { PersistentMemory } from '#agent/memory/PersistentMemory.js';
|
|
24
24
|
import { SessionStore } from '#agent/memory/SessionStore.js';
|
|
25
25
|
import { PRESETS } from '#agent/presets.js';
|
|
26
|
+
import { getDimensionFocusKeywords } from '#domain/dimension/DimensionSop.js';
|
|
26
27
|
import Logger from '#infra/logging/Logger.js';
|
|
27
28
|
import { BootstrapEventEmitter } from '#service/bootstrap/BootstrapEventEmitter.js';
|
|
28
|
-
import {
|
|
29
|
+
import { buildEvidenceStarters } from '../MissionBriefingBuilder.js';
|
|
29
30
|
import { generateSkill } from '../shared/skill-generator.js';
|
|
30
31
|
import { clearCheckpoints, loadCheckpoints, saveDimensionCheckpoint } from './checkpoint.js';
|
|
31
32
|
import { buildTierReflection, DIMENSION_CONFIGS_V3, getFullDimensionConfig, } from './dimension-configs.js';
|
|
32
33
|
import { DimensionContext, parseDimensionDigest } from './dimension-context.js';
|
|
33
34
|
import { IncrementalBootstrap } from './IncrementalBootstrap.js';
|
|
34
|
-
import {
|
|
35
|
+
import { fillDimensionsMock } from './mock-pipeline.js';
|
|
35
36
|
import { TierScheduler } from './tier-scheduler.js';
|
|
36
37
|
const logger = Logger.getInstance();
|
|
37
38
|
// ──────────────────────────────────────────────────────────────────
|
|
38
39
|
// Panorama Context for strategyContext injection (M1 §5.2)
|
|
39
40
|
// ──────────────────────────────────────────────────────────────────
|
|
40
41
|
/**
|
|
41
|
-
* 从
|
|
42
|
+
* 从 panoramaResult 提取维度级全景上下文
|
|
42
43
|
* 注入 strategyContext.panorama,使 Agent 获得模块角色/层级/耦合/空白区信息
|
|
43
44
|
*/
|
|
44
|
-
function buildPanoramaContext(
|
|
45
|
-
const panoramaResult = fillContext.panoramaResult;
|
|
45
|
+
function buildPanoramaContext(panoramaResult, _dimConfig) {
|
|
46
46
|
if (!panoramaResult) {
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
@@ -87,172 +87,77 @@ function buildPanoramaContext(fillContext, _dimConfig) {
|
|
|
87
87
|
/**
|
|
88
88
|
* fillDimensionsV3 — v3.0 AI-First 维度填充管线
|
|
89
89
|
*
|
|
90
|
-
* @param
|
|
90
|
+
* @param view PipelineFillView — 从 handler 传入的类型化视图
|
|
91
|
+
* @param dimensions 当前运行的维度列表(rescan 可能是 gap 子集)
|
|
91
92
|
*/
|
|
92
|
-
export async function fillDimensionsV3(
|
|
93
|
-
const {
|
|
94
|
-
|
|
93
|
+
export async function fillDimensionsV3(view, dimensions) {
|
|
94
|
+
const { snapshot, projectRoot } = view;
|
|
95
|
+
const ctx = view.ctx;
|
|
96
|
+
// 从 snapshot 提取 orchestrator 所需字段
|
|
97
|
+
const depGraphData = snapshot.dependencyGraph;
|
|
98
|
+
const guardAudit = snapshot.guardAudit;
|
|
99
|
+
const primaryLang = snapshot.language.primaryLang ?? 'unknown';
|
|
100
|
+
const astProjectSummary = snapshot.ast;
|
|
101
|
+
const incrementalPlan = snapshot.incrementalPlan;
|
|
102
|
+
const panoramaResult = snapshot.panorama;
|
|
103
|
+
const callGraphResult = snapshot.callGraph;
|
|
104
|
+
const existingRecipes = view.existingRecipes ?? null;
|
|
105
|
+
const targetFileMap = view.targetFileMap;
|
|
106
|
+
// 从 ctx 获取运行时服务
|
|
107
|
+
let taskManager = null;
|
|
108
|
+
try {
|
|
109
|
+
taskManager = ctx.container.get('bootstrapTaskManager');
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
/* not available */
|
|
113
|
+
}
|
|
114
|
+
const sessionId = view.bootstrapSession?.id ?? '';
|
|
95
115
|
const isIncremental = incrementalPlan?.canIncremental && incrementalPlan?.mode === 'incremental';
|
|
96
116
|
const emitter = new BootstrapEventEmitter(ctx.container);
|
|
97
117
|
logger.info(`[Insight-v3] ═══ fillDimensionsV3 entered — ${isIncremental ? 'INCREMENTAL' : 'FULL'} pipeline`);
|
|
98
|
-
let allFiles =
|
|
99
|
-
fillContext.allFiles = null;
|
|
118
|
+
let allFiles = snapshot.allFiles;
|
|
100
119
|
// ═══════════════════════════════════════════════════════════
|
|
101
|
-
// Step 0: AI 可用性检查 (v7.2: 使用 AgentFactory)
|
|
120
|
+
// Step 0: AI 可用性检查 (v7.2: 使用 AgentFactory + AiProviderManager)
|
|
102
121
|
// ═══════════════════════════════════════════════════════════
|
|
103
122
|
let agentFactory = null;
|
|
123
|
+
let isMockMode = false;
|
|
104
124
|
try {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (!
|
|
109
|
-
agentFactory =
|
|
125
|
+
// 通过 AiProviderManager 统一检查 mock 模式
|
|
126
|
+
const manager = ctx.container.singletons?._aiProviderManager;
|
|
127
|
+
isMockMode = manager?.isMock ?? false;
|
|
128
|
+
if (!isMockMode) {
|
|
129
|
+
agentFactory = ctx.container.get('agentFactory');
|
|
110
130
|
}
|
|
111
131
|
}
|
|
112
132
|
catch {
|
|
113
133
|
/* not available */
|
|
114
134
|
}
|
|
115
|
-
if (!agentFactory) {
|
|
116
|
-
logger.
|
|
135
|
+
if (!agentFactory && !isMockMode) {
|
|
136
|
+
logger.error('[Insight-v3] AI Provider not available — bootstrap requires AI');
|
|
117
137
|
emitter.emitProgress('bootstrap:ai-unavailable', {
|
|
118
|
-
message: 'AI
|
|
138
|
+
message: 'AI Provider 不可用,Bootstrap 需要 AI 才能运行。请先配置 AI Provider(如 OpenAI、Anthropic 等)后重试。',
|
|
119
139
|
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
fillContext.allFiles = allFiles;
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- FillContextV3 is structurally compatible with FillContext at runtime
|
|
124
|
-
const fallbackResult = await runNoAiFallback(fillContext);
|
|
125
|
-
// ── 持久化候选到数据库 (KnowledgeService.create) ──
|
|
126
|
-
let persistedCount = 0;
|
|
127
|
-
if (fallbackResult.candidates.length > 0) {
|
|
128
|
-
try {
|
|
129
|
-
const knowledgeService = ctx.container.get('knowledgeService');
|
|
130
|
-
for (const candidate of fallbackResult.candidates) {
|
|
131
|
-
try {
|
|
132
|
-
await knowledgeService.create({
|
|
133
|
-
title: candidate.title,
|
|
134
|
-
content: candidate.content,
|
|
135
|
-
language: candidate.language || primaryLang || '',
|
|
136
|
-
category: candidate.category || '',
|
|
137
|
-
knowledgeType: candidate.knowledgeType || 'code-pattern',
|
|
138
|
-
source: 'bootstrap-fallback',
|
|
139
|
-
difficulty: candidate.difficulty || 'beginner',
|
|
140
|
-
scope: candidate.scope || 'project-specific',
|
|
141
|
-
reasoning: candidate.reasoning || {},
|
|
142
|
-
tags: ['bootstrap-fallback', 'rule-based'],
|
|
143
|
-
trigger: candidate.trigger || '',
|
|
144
|
-
doClause: candidate.doClause || '',
|
|
145
|
-
dontClause: candidate.dontClause || '',
|
|
146
|
-
whenClause: candidate.whenClause || '',
|
|
147
|
-
coreCode: candidate.coreCode || '',
|
|
148
|
-
}, { userId: 'bootstrap-fallback' });
|
|
149
|
-
persistedCount++;
|
|
150
|
-
}
|
|
151
|
-
catch (entryErr) {
|
|
152
|
-
logger.warn(`[Bootstrap-fallback] Candidate "${candidate.title}" persist failed: ${entryErr instanceof Error ? entryErr.message : String(entryErr)}`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
logger.info(`[Bootstrap-fallback] ${persistedCount}/${fallbackResult.candidates.length} candidates persisted to DB`);
|
|
156
|
-
}
|
|
157
|
-
catch (svcErr) {
|
|
158
|
-
logger.warn(`[Bootstrap-fallback] KnowledgeService not available — candidates not persisted: ${svcErr instanceof Error ? svcErr.message : String(svcErr)}`);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// ── 持久化 Skill 文件 ──
|
|
162
|
-
let skillsCreated = 0;
|
|
163
|
-
if (fallbackResult.skills.length > 0) {
|
|
164
|
-
try {
|
|
165
|
-
const { createSkill } = await import('../../skill.js');
|
|
166
|
-
for (const sk of fallbackResult.skills) {
|
|
167
|
-
try {
|
|
168
|
-
const result = createSkill(ctx, {
|
|
169
|
-
name: sk.name,
|
|
170
|
-
description: sk.description,
|
|
171
|
-
content: sk.content,
|
|
172
|
-
overwrite: true,
|
|
173
|
-
createdBy: 'bootstrap-fallback',
|
|
174
|
-
});
|
|
175
|
-
const parsed = JSON.parse(result);
|
|
176
|
-
if (parsed.success) {
|
|
177
|
-
skillsCreated++;
|
|
178
|
-
logger.info(`[Bootstrap-fallback] Skill "${sk.name}" created`);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
catch (skErr) {
|
|
182
|
-
logger.warn(`[Bootstrap-fallback] Skill "${sk.name}" write failed: ${skErr instanceof Error ? skErr.message : String(skErr)}`);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
catch (importErr) {
|
|
187
|
-
logger.warn(`[Bootstrap-fallback] Skill module import failed: ${importErr instanceof Error ? importErr.message : String(importErr)}`);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
// ── 写入降级报告 ──
|
|
191
|
-
try {
|
|
192
|
-
const reportDir = path.join(projectRoot, '.autosnippet');
|
|
193
|
-
await fs.mkdir(reportDir, { recursive: true });
|
|
194
|
-
await fs.writeFile(path.join(reportDir, 'bootstrap-report.json'), JSON.stringify({
|
|
195
|
-
version: '2.7.0',
|
|
196
|
-
timestamp: new Date().toISOString(),
|
|
197
|
-
mode: 'no-ai-fallback',
|
|
198
|
-
project: {
|
|
199
|
-
name: path.basename(projectRoot),
|
|
200
|
-
files: allFiles?.length || 0,
|
|
201
|
-
lang: primaryLang || 'unknown',
|
|
202
|
-
},
|
|
203
|
-
fallback: fallbackResult.report,
|
|
204
|
-
persisted: { candidates: persistedCount, skills: skillsCreated },
|
|
205
|
-
}, null, 2));
|
|
206
|
-
}
|
|
207
|
-
catch {
|
|
208
|
-
/* non-critical */
|
|
209
|
-
}
|
|
210
|
-
// ── 通知前端降级产出已完成 ──
|
|
211
|
-
emitter.emitProgress('bootstrap:fallback-complete', {
|
|
212
|
-
message: `降级产出完成: ${persistedCount} 条知识已入库, ${skillsCreated} 个 Skill 已生成`,
|
|
213
|
-
candidates: persistedCount,
|
|
214
|
-
skills: skillsCreated,
|
|
215
|
-
errors: fallbackResult.report.errors.length,
|
|
216
|
-
});
|
|
217
|
-
// ── R7: No-AI 降级路径完成后也触发 Cursor Delivery ──
|
|
218
|
-
if (persistedCount > 0 || skillsCreated > 0) {
|
|
219
|
-
try {
|
|
220
|
-
const { getServiceContainer } = await import('#inject/ServiceContainer.js');
|
|
221
|
-
const deliveryContainer = getServiceContainer();
|
|
222
|
-
if (deliveryContainer.services.cursorDeliveryPipeline) {
|
|
223
|
-
const pipeline = deliveryContainer.get('cursorDeliveryPipeline');
|
|
224
|
-
const deliveryResult = await pipeline.deliver();
|
|
225
|
-
logger.info(`[Bootstrap-fallback] Cursor Delivery complete — ` +
|
|
226
|
-
`A: ${deliveryResult.channelA?.rulesCount || 0}, ` +
|
|
227
|
-
`B: ${deliveryResult.channelB?.topicCount || 0}, ` +
|
|
228
|
-
`F: ${deliveryResult.channelF?.filesWritten || 0}`);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
catch (deliveryErr) {
|
|
232
|
-
logger.warn(`[Bootstrap-fallback] CursorDelivery failed (non-blocking): ${deliveryErr instanceof Error ? deliveryErr.message : String(deliveryErr)}`);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
logger.info(`[Bootstrap-fallback] Completed: ${persistedCount} candidates persisted, ` +
|
|
236
|
-
`${skillsCreated} skills written, ${fallbackResult.report.errors.length} errors`);
|
|
237
|
-
}
|
|
238
|
-
catch (fallbackErr) {
|
|
239
|
-
logger.error(`[Bootstrap-fallback] Fallback failed: ${fallbackErr instanceof Error ? fallbackErr.message : String(fallbackErr)}`);
|
|
240
|
-
// 即使降级也失败,仍标记所有维度为 skipped
|
|
241
|
-
for (const dim of dimensions) {
|
|
242
|
-
emitter.emitDimensionComplete(dim.id, { type: 'skipped', reason: 'fallback-failed' });
|
|
243
|
-
}
|
|
140
|
+
for (const dim of dimensions) {
|
|
141
|
+
emitter.emitDimensionComplete(dim.id, { type: 'skipped', reason: 'ai-unavailable' });
|
|
244
142
|
}
|
|
245
143
|
return;
|
|
246
144
|
}
|
|
145
|
+
// Mock AI: 走 mock-pipeline 轻量管线
|
|
146
|
+
if (isMockMode) {
|
|
147
|
+
logger.info('[Insight-v3] Mock AI detected — routing to mock-pipeline');
|
|
148
|
+
await fillDimensionsMock(view, dimensions);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
247
151
|
// ═══════════════════════════════════════════════════════════
|
|
248
152
|
// Step 0.5: 构建 ProjectGraph
|
|
249
153
|
// ═══════════════════════════════════════════════════════════
|
|
250
154
|
let projectGraph = null;
|
|
251
155
|
try {
|
|
252
|
-
projectGraph =
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
156
|
+
projectGraph =
|
|
157
|
+
(await ctx.container.buildProjectGraph?.(projectRoot, {
|
|
158
|
+
maxFiles: 500,
|
|
159
|
+
timeoutMs: 15_000,
|
|
160
|
+
})) ?? null;
|
|
256
161
|
if (projectGraph) {
|
|
257
162
|
const overview = projectGraph.getOverview();
|
|
258
163
|
logger.info(`[Insight-v3] ProjectGraph: ${overview.totalClasses} classes, ${overview.totalProtocols} protocols (${overview.buildTimeMs}ms)`);
|
|
@@ -278,11 +183,11 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
278
183
|
projectName: projectInfo.name,
|
|
279
184
|
primaryLang: projectInfo.lang,
|
|
280
185
|
fileCount: projectInfo.fileCount,
|
|
281
|
-
targetCount: Object.keys(
|
|
282
|
-
modules: Object.keys(
|
|
283
|
-
depGraph: depGraphData
|
|
284
|
-
astMetrics: astProjectSummary?.projectMetrics
|
|
285
|
-
guardSummary: guardAudit?.summary
|
|
186
|
+
targetCount: Object.keys(targetFileMap || {}).length,
|
|
187
|
+
modules: Object.keys(targetFileMap || {}),
|
|
188
|
+
depGraph: depGraphData ?? undefined,
|
|
189
|
+
astMetrics: astProjectSummary?.projectMetrics ?? undefined,
|
|
190
|
+
guardSummary: guardAudit?.summary ?? undefined,
|
|
286
191
|
});
|
|
287
192
|
// v4.0: SessionStore — 替代 EpisodicMemory + ToolResultCache
|
|
288
193
|
// v5.0: 增量模式下从快照恢复已完成维度的记忆
|
|
@@ -304,7 +209,7 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
304
209
|
projectName: projectInfo.name,
|
|
305
210
|
primaryLang: projectInfo.lang,
|
|
306
211
|
fileCount: projectInfo.fileCount,
|
|
307
|
-
modules: Object.keys(
|
|
212
|
+
modules: Object.keys(targetFileMap || {}),
|
|
308
213
|
});
|
|
309
214
|
}
|
|
310
215
|
// v4.1: PersistentMemory — 项目级永久语义记忆 (Tier 3)
|
|
@@ -414,6 +319,36 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
414
319
|
// ── 跨维度去重集合 (实例级持久化,等效旧 ChatAgent.#globalSubmittedTitles/Patterns) ──
|
|
415
320
|
const globalSubmittedTitles = new Set();
|
|
416
321
|
const globalSubmittedPatterns = new Set();
|
|
322
|
+
// ── Rescan 模式: 预种已有 recipe 标题到去重集合,防止重复创建 ──
|
|
323
|
+
const existingRecipesList = existingRecipes;
|
|
324
|
+
if (existingRecipesList && existingRecipesList.length > 0) {
|
|
325
|
+
for (const r of existingRecipesList) {
|
|
326
|
+
// ★ 只预种 healthy 标题,decaying 的允许被替代
|
|
327
|
+
if (r.title && r.status !== 'decaying') {
|
|
328
|
+
globalSubmittedTitles.add(r.title.toLowerCase().trim());
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
logger.info(`[Insight-v3] Rescan mode: seeded ${globalSubmittedTitles.size} existing recipe titles into dedup set`);
|
|
332
|
+
}
|
|
333
|
+
// 构建 rescanContext 供 Analyst/Producer prompt 使用(区分 healthy/decaying)
|
|
334
|
+
const rescanContext = existingRecipesList
|
|
335
|
+
? {
|
|
336
|
+
// healthy 列表 — 告诉 Agent "不要重复"
|
|
337
|
+
existingRecipes: existingRecipesList.filter((r) => r.status !== 'decaying'),
|
|
338
|
+
// decaying 列表 — 告诉 Agent "可以替换"
|
|
339
|
+
decayingRecipes: existingRecipesList.filter((r) => r.status === 'decaying'),
|
|
340
|
+
// trigger 仍全部占用(含 decaying)
|
|
341
|
+
occupiedTriggers: existingRecipesList.map((r) => r.trigger).filter(Boolean),
|
|
342
|
+
coverageByDim: existingRecipesList.reduce((acc, r) => {
|
|
343
|
+
// 只有 healthy 计入覆盖
|
|
344
|
+
if (r.status !== 'decaying') {
|
|
345
|
+
const dim = r.knowledgeType || 'unknown';
|
|
346
|
+
acc[dim] = (acc[dim] || 0) + 1;
|
|
347
|
+
}
|
|
348
|
+
return acc;
|
|
349
|
+
}, {}),
|
|
350
|
+
}
|
|
351
|
+
: null;
|
|
417
352
|
/** 执行单个维度: Analyst → Gate → Producer */
|
|
418
353
|
async function executeDimension(dimId) {
|
|
419
354
|
// v5.0: 增量模式 — 跳过未受影响的维度 (使用历史 EpisodicMemory)
|
|
@@ -530,15 +465,22 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
530
465
|
: !dimConfig.skillWorthy || dimConfig.dualOutput;
|
|
531
466
|
// ── 获取 Preset 的标准 stages 配置作为基础 ──
|
|
532
467
|
const presetStages = PRESETS.insight.strategy.stages;
|
|
468
|
+
const evolutionPresetStages = PRESETS.evolution.strategy.stages;
|
|
469
|
+
// ── 判断当前维度是否有现有 Recipe(按维度过滤后) ──
|
|
470
|
+
const dimExistingRecipes = [
|
|
471
|
+
...(rescanContext?.existingRecipes?.filter((r) => r.knowledgeType === dimId) ?? []),
|
|
472
|
+
...(rescanContext?.decayingRecipes?.filter((r) => r.knowledgeType === dimId) ?? []),
|
|
473
|
+
];
|
|
474
|
+
const hasExistingRecipes = dimExistingRecipes.length > 0;
|
|
533
475
|
// ── 构建 per-dimension 的 stages ──
|
|
534
476
|
// NOTE: onToolCall 不再注入 ac.recordToolCall — ToolExecutionPipeline 的
|
|
535
477
|
// traceRecord 中间件已通过 loopCtx.trace 统一记录,避免同一 AC 上双重记录。
|
|
536
478
|
const analyzeStage = {
|
|
537
479
|
...presetStages[0],
|
|
538
480
|
};
|
|
481
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- pipeline stage shapes from PRESETS; needs PipelineStage interface (T4)
|
|
539
482
|
let stages;
|
|
540
483
|
if (needsCandidates) {
|
|
541
|
-
// 候选维度: Analyze→QualityGate→Produce→RejectionGate
|
|
542
484
|
const produceStage = {
|
|
543
485
|
...presetStages[2],
|
|
544
486
|
promptBuilder: (ctx) => {
|
|
@@ -546,12 +488,26 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
546
488
|
return presetStages[2].promptBuilder?.(ctx);
|
|
547
489
|
},
|
|
548
490
|
};
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
491
|
+
if (hasExistingRecipes) {
|
|
492
|
+
// 当前维度有旧 Recipe: Evolve→EvolutionGate→Analyze→QualityGate→Produce→RejectionGate
|
|
493
|
+
stages = [
|
|
494
|
+
evolutionPresetStages[0], // evolve
|
|
495
|
+
evolutionPresetStages[1], // evolution_gate
|
|
496
|
+
analyzeStage,
|
|
497
|
+
presetStages[1], // quality_gate
|
|
498
|
+
produceStage,
|
|
499
|
+
presetStages[3], // rejection_gate
|
|
500
|
+
];
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
// 当前维度无旧 Recipe: Analyze→QualityGate→Produce→RejectionGate
|
|
504
|
+
stages = [
|
|
505
|
+
analyzeStage,
|
|
506
|
+
presetStages[1], // quality_gate
|
|
507
|
+
produceStage,
|
|
508
|
+
presetStages[3], // rejection_gate
|
|
509
|
+
];
|
|
510
|
+
}
|
|
555
511
|
}
|
|
556
512
|
else {
|
|
557
513
|
// Skill-only 维度: 仅 Analyze
|
|
@@ -585,9 +541,53 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
585
541
|
activeContext: memoryCoordinator.getActiveContext(analystScopeId),
|
|
586
542
|
outputType: dimConfig.outputType || 'analysis',
|
|
587
543
|
// §M1: Panorama 全景上下文 (Phase 1.8 数据注入)
|
|
588
|
-
panorama: buildPanoramaContext(
|
|
544
|
+
panorama: buildPanoramaContext(panoramaResult, dimConfig),
|
|
545
|
+
// §ES: Evidence Starters — 从 Phase 1-4 数据提取维度级证据启发
|
|
546
|
+
evidenceStarters: buildEvidenceStarters(dimConfig, {
|
|
547
|
+
astData: astProjectSummary,
|
|
548
|
+
guardAudit,
|
|
549
|
+
depGraphData,
|
|
550
|
+
callGraphResult,
|
|
551
|
+
panoramaResult,
|
|
552
|
+
}),
|
|
553
|
+
// §R1: Rescan 模式 — 已有 recipe 上下文 (避免重复分析/创建)
|
|
554
|
+
rescanContext: rescanContext
|
|
555
|
+
? {
|
|
556
|
+
existingRecipes: rescanContext.existingRecipes.filter((r) => r.knowledgeType === dimId),
|
|
557
|
+
decayingRecipes: rescanContext.decayingRecipes.filter((r) => r.knowledgeType === dimId),
|
|
558
|
+
occupiedTriggers: rescanContext.occupiedTriggers,
|
|
559
|
+
gap: Math.max(0, 5 - (rescanContext.coverageByDim[dimId] || 0)),
|
|
560
|
+
existing: rescanContext.coverageByDim[dimId] || 0,
|
|
561
|
+
}
|
|
562
|
+
: null,
|
|
563
|
+
// §EVO: Evolution Stage — 当前维度全部现有 Recipe(healthy + decaying),附带 audit hint
|
|
564
|
+
existingRecipes: dimExistingRecipes.map((r) => ({
|
|
565
|
+
id: r.id,
|
|
566
|
+
title: r.title,
|
|
567
|
+
trigger: r.trigger,
|
|
568
|
+
content: r.content,
|
|
569
|
+
sourceRefs: r.sourceRefs,
|
|
570
|
+
auditHint: 'auditScore' in r && r.auditScore != null
|
|
571
|
+
? {
|
|
572
|
+
relevanceScore: r.auditScore,
|
|
573
|
+
verdict: r.status === 'decaying' ? 'decay' : 'watch',
|
|
574
|
+
evidence: r.auditEvidence ?? {},
|
|
575
|
+
decayReasons: r.decayReason
|
|
576
|
+
? [String(r.decayReason)]
|
|
577
|
+
: [],
|
|
578
|
+
}
|
|
579
|
+
: null,
|
|
580
|
+
})),
|
|
581
|
+
// Evolution 上下文字段 — buildEvolverPrompt 直接从 strategyContext 读取
|
|
582
|
+
dimensionId: dimId,
|
|
583
|
+
dimensionLabel: dimConfig.label,
|
|
584
|
+
projectOverview: {
|
|
585
|
+
primaryLang: primaryLang || projectInfo.lang || 'unknown',
|
|
586
|
+
fileCount: projectInfo.fileCount || 0,
|
|
587
|
+
modules: Object.keys(targetFileMap || {}),
|
|
588
|
+
},
|
|
589
589
|
// ── 引擎增强参数 (PipelineStrategy → reactLoop 透传) ──
|
|
590
|
-
contextWindow: agentFactory
|
|
590
|
+
contextWindow: agentFactory?.createContextWindow({ isSystem: true }),
|
|
591
591
|
// B1 fix: 分析阶段使用 analyst 策略 (SCAN→EXPLORE→VERIFY→SUMMARIZE)
|
|
592
592
|
// 而非 bootstrap (EXPLORE→PRODUCE→SUMMARIZE),避免 PRODUCE nudge 浪费轮次
|
|
593
593
|
// B3 fix: 透传完整 ANALYST_BUDGET (searchBudget/maxSubmits/softSubmitLimit/idleRoundsToExit)
|
|
@@ -609,7 +609,7 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
609
609
|
};
|
|
610
610
|
// ── 执行 ──
|
|
611
611
|
// 外层超时 = 安全网 (各阶段已有独立超时: Analyst 300s + Producer 180s + 硬缓冲 60s)
|
|
612
|
-
const outerTimeoutMs =
|
|
612
|
+
const outerTimeoutMs = 3_600_000; // 1 小时——维度分析本身耗时长
|
|
613
613
|
const runResult = await Promise.race([
|
|
614
614
|
runtime.execute(message, { strategyContext }),
|
|
615
615
|
new Promise((_, reject) => setTimeout(() => reject(new Error(`Bootstrap runtime timeout for "${dimId}"`)), outerTimeoutMs)),
|
|
@@ -686,6 +686,26 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
686
686
|
};
|
|
687
687
|
candidateResults.created += producerResult.candidateCount;
|
|
688
688
|
dimensionCandidates[dimId] = { analysisReport, producerResult };
|
|
689
|
+
// ── Producer 阶段详细日志 ──
|
|
690
|
+
if (needsCandidates) {
|
|
691
|
+
const producerToolCalls = produceResult?.toolCalls || [];
|
|
692
|
+
const producerToolNames = producerToolCalls.map((tc) => tc?.tool || tc?.name || 'unknown');
|
|
693
|
+
const toolBreakdown = {};
|
|
694
|
+
for (const name of producerToolNames) {
|
|
695
|
+
toolBreakdown[name] = (toolBreakdown[name] || 0) + 1;
|
|
696
|
+
}
|
|
697
|
+
const breakdownStr = Object.entries(toolBreakdown)
|
|
698
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
699
|
+
.join(', ');
|
|
700
|
+
logger.info(`[Producer] "${dimId}": submitted=${submitCalls.length}, accepted=${successCount}, rejected=${rejectedCount}, ` +
|
|
701
|
+
`producerToolCalls=${producerToolCalls.length} (${breakdownStr || 'none'}), ` +
|
|
702
|
+
`analysisInput=${analysisText.length} chars`);
|
|
703
|
+
if (successCount === 0 && submitCalls.length === 0) {
|
|
704
|
+
logger.warn(`[Producer] "${dimId}": ⚠ Producer 未提交任何候选。` +
|
|
705
|
+
`分析文本=${analysisText.length} chars, findings=${(analysisReport.findings || []).length}, ` +
|
|
706
|
+
`producerIterations=${producerToolCalls.length}, degraded=${runResult?.degraded || false}`);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
689
709
|
// ── Memory Update ──
|
|
690
710
|
const ac = memoryCoordinator.getActiveContext(analystScopeId);
|
|
691
711
|
const distilled = ac
|
|
@@ -866,9 +886,9 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
866
886
|
logger.info(`[Insight-v3] Memory stats: ${emStats.completedDimensions} dims, ` +
|
|
867
887
|
`${emStats.totalFindings} findings, ${emStats.referencedFiles} files, ` +
|
|
868
888
|
`${emStats.crossReferences} cross-refs, ${emStats.tierReflections} reflections`);
|
|
869
|
-
if (emStats.
|
|
870
|
-
logger.info(`[Insight-v3] Cache stats: ${emStats.
|
|
871
|
-
`${emStats.
|
|
889
|
+
if (emStats.cache) {
|
|
890
|
+
logger.info(`[Insight-v3] Cache stats: ${emStats.cache.hitRate} hit rate, ` +
|
|
891
|
+
`${emStats.cache.searchCacheSize} searches, ${emStats.cache.fileCacheSize} files`);
|
|
872
892
|
}
|
|
873
893
|
}
|
|
874
894
|
else {
|
|
@@ -910,9 +930,8 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
910
930
|
const referencedFiles = dimData.analysisReport.referencedFiles || [];
|
|
911
931
|
// 从 SessionStore 获取结构化发现,供 Skill 生成使用
|
|
912
932
|
const dimReport = sessionStore.getDimensionReport(dim.id);
|
|
913
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- SessionStore Finding type varies
|
|
914
933
|
const keyFindings = (dimReport?.findings || [])
|
|
915
|
-
.sort((a, b) => (b.importance || 5) - (a.importance || 5))
|
|
934
|
+
.sort((a, b) => (Number(b.importance) || 5) - (Number(a.importance) || 5))
|
|
916
935
|
.slice(0, 10)
|
|
917
936
|
.map((f) => String(f.finding || ''));
|
|
918
937
|
// 当 analysisText 过短(如 force-exit 时 AI 仅输出 JSON digest 被清洗后)
|
|
@@ -16,28 +16,18 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @module TierScheduler
|
|
18
18
|
*/
|
|
19
|
+
import { buildTierPlan } from '#domain/dimension/index.js';
|
|
19
20
|
import Logger from '#infra/logging/Logger.js';
|
|
20
21
|
import { createLimit } from '#shared/concurrency.js';
|
|
21
22
|
const logger = Logger.getInstance();
|
|
22
23
|
// ──────────────────────────────────────────────────────────────────
|
|
23
|
-
// 分层定义
|
|
24
|
+
// 分层定义 — 从统一注册表动态生成
|
|
24
25
|
// ──────────────────────────────────────────────────────────────────
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'category-scan',
|
|
31
|
-
'module-export-scan',
|
|
32
|
-
'framework-convention-scan',
|
|
33
|
-
'python-package-scan',
|
|
34
|
-
'jvm-annotation-scan',
|
|
35
|
-
],
|
|
36
|
-
// Tier 2: 规范+架构+模式
|
|
37
|
-
['code-standard', 'architecture', 'code-pattern'],
|
|
38
|
-
// Tier 3: 流转+实践+总结
|
|
39
|
-
['event-and-data-flow', 'best-practice', 'agent-guidelines'],
|
|
40
|
-
];
|
|
26
|
+
/**
|
|
27
|
+
* 默认分层来自 DimensionRegistry.buildTierPlan(),
|
|
28
|
+
* 该函数根据每个维度的 tierHint 自动分配。
|
|
29
|
+
*/
|
|
30
|
+
const DEFAULT_TIERS = buildTierPlan();
|
|
41
31
|
// ──────────────────────────────────────────────────────────────────
|
|
42
32
|
// TierScheduler
|
|
43
33
|
// ──────────────────────────────────────────────────────────────────
|
|
@@ -21,6 +21,14 @@ export async function bootstrapRefine(ctx, args) {
|
|
|
21
21
|
errorCode: 'MISSING_AI_PROVIDER',
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
// Mock 模式下跳过 AI 润色
|
|
25
|
+
if (aiProvider.name === 'mock') {
|
|
26
|
+
return envelope({
|
|
27
|
+
success: false,
|
|
28
|
+
message: 'AI Provider 未配置,当前为 Mock 模式。请先配置 API Key。',
|
|
29
|
+
errorCode: 'MOCK_MODE',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
24
32
|
// 接入 BootstrapTaskManager 双通道推送 refine:* 事件
|
|
25
33
|
let onProgress = null;
|
|
26
34
|
try {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for async AI-fill pipeline dispatch.
|
|
3
|
+
*
|
|
4
|
+
* Previously duplicated in:
|
|
5
|
+
* - bootstrap-internal.ts (Phase 5)
|
|
6
|
+
* - rescan-internal.ts (Step 6-7)
|
|
7
|
+
*
|
|
8
|
+
* @module bootstrap/shared/async-fill-helpers
|
|
9
|
+
*/
|
|
10
|
+
import type { BootstrapSessionShape, DimensionDef } from '#types/project-snapshot.js';
|
|
11
|
+
import type { PipelineFillView } from '#types/snapshot-views.js';
|
|
12
|
+
import type { McpContext } from '../../types.js';
|
|
13
|
+
interface TaskDef {
|
|
14
|
+
id: string;
|
|
15
|
+
meta: {
|
|
16
|
+
type: string;
|
|
17
|
+
dimId: string;
|
|
18
|
+
label: string | undefined;
|
|
19
|
+
skillWorthy: boolean;
|
|
20
|
+
skillMeta: Record<string, unknown> | null;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Build task definitions from dimensions for BootstrapTaskManager.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildTaskDefs(dimensions: DimensionDef[]): TaskDef[];
|
|
27
|
+
interface TaskManagerLogger {
|
|
28
|
+
warn(...args: unknown[]): void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Start a BootstrapTaskManager session (graceful degradation if unavailable).
|
|
32
|
+
*/
|
|
33
|
+
export declare function startTaskManagerSession(container: McpContext['container'], taskDefs: TaskDef[], logger: TaskManagerLogger, logPrefix: string): BootstrapSessionShape | null;
|
|
34
|
+
/**
|
|
35
|
+
* Dispatch fillDimensionsV3 from a PipelineFillView.
|
|
36
|
+
*
|
|
37
|
+
* Passes the view directly to orchestrator (no more flat-context expansion).
|
|
38
|
+
* Fires via setImmediate (fire-and-forget).
|
|
39
|
+
*
|
|
40
|
+
* @param view - Typed PipelineFillView from handler
|
|
41
|
+
* @param dimensions - Active dimensions for this run (may differ from snapshot.activeDimensions for rescan gap-only)
|
|
42
|
+
* @param fillDimensionsV3 - The pipeline function to invoke
|
|
43
|
+
* @param logPrefix - Log prefix (e.g. 'Bootstrap', 'Rescan-Internal')
|
|
44
|
+
*/
|
|
45
|
+
export declare function dispatchPipelineFill(view: PipelineFillView, dimensions: DimensionDef[], fillDimensionsV3: (view: PipelineFillView, dimensions: DimensionDef[]) => Promise<void>, logPrefix: string): void;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for async AI-fill pipeline dispatch.
|
|
3
|
+
*
|
|
4
|
+
* Previously duplicated in:
|
|
5
|
+
* - bootstrap-internal.ts (Phase 5)
|
|
6
|
+
* - rescan-internal.ts (Step 6-7)
|
|
7
|
+
*
|
|
8
|
+
* @module bootstrap/shared/async-fill-helpers
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Build task definitions from dimensions for BootstrapTaskManager.
|
|
12
|
+
*/
|
|
13
|
+
export function buildTaskDefs(dimensions) {
|
|
14
|
+
return dimensions.map((dim) => ({
|
|
15
|
+
id: dim.id,
|
|
16
|
+
meta: {
|
|
17
|
+
type: dim.skillWorthy ? 'skill' : 'candidate',
|
|
18
|
+
dimId: dim.id,
|
|
19
|
+
label: dim.label,
|
|
20
|
+
skillWorthy: !!dim.skillWorthy,
|
|
21
|
+
skillMeta: dim.skillMeta || null,
|
|
22
|
+
},
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Start a BootstrapTaskManager session (graceful degradation if unavailable).
|
|
27
|
+
*/
|
|
28
|
+
export function startTaskManagerSession(container, taskDefs, logger, logPrefix) {
|
|
29
|
+
try {
|
|
30
|
+
const taskManager = container.get('bootstrapTaskManager');
|
|
31
|
+
return taskManager.startSession(taskDefs);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
logger.warn(`[${logPrefix}] BootstrapTaskManager init failed (graceful degradation): ${e instanceof Error ? e.message : String(e)}`);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// ── Pipeline Fill View dispatch (Phase D-2) ──────────────
|
|
39
|
+
/**
|
|
40
|
+
* Dispatch fillDimensionsV3 from a PipelineFillView.
|
|
41
|
+
*
|
|
42
|
+
* Passes the view directly to orchestrator (no more flat-context expansion).
|
|
43
|
+
* Fires via setImmediate (fire-and-forget).
|
|
44
|
+
*
|
|
45
|
+
* @param view - Typed PipelineFillView from handler
|
|
46
|
+
* @param dimensions - Active dimensions for this run (may differ from snapshot.activeDimensions for rescan gap-only)
|
|
47
|
+
* @param fillDimensionsV3 - The pipeline function to invoke
|
|
48
|
+
* @param logPrefix - Log prefix (e.g. 'Bootstrap', 'Rescan-Internal')
|
|
49
|
+
*/
|
|
50
|
+
export function dispatchPipelineFill(view, dimensions, fillDimensionsV3, logPrefix) {
|
|
51
|
+
const ctxLogger = view.ctx.logger;
|
|
52
|
+
setImmediate(() => {
|
|
53
|
+
ctxLogger?.info(`[${logPrefix}] Dispatching v3 AI-First pipeline`);
|
|
54
|
+
fillDimensionsV3(view, dimensions).catch((e) => {
|
|
55
|
+
ctxLogger?.error(`[${logPrefix}] Async fill failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|