autosnippet 3.3.5 → 3.3.6
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-D1aVZYFW.js +1 -0
- package/dashboard/dist/assets/index-CxHOu8Hd.css +1 -0
- package/dashboard/dist/assets/index-DDdAOpYT.js +128 -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 +136 -9
- package/dist/lib/agent/AgentFactory.d.ts +0 -17
- package/dist/lib/agent/AgentFactory.js +1 -25
- 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/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/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 +1 -1
- package/dist/lib/cli/KnowledgeSyncService.js +1 -1
- package/dist/lib/core/AstAnalyzer.d.ts +1 -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 +33 -111
- package/dist/lib/domain/knowledge/KnowledgeEntry.js +27 -6
- 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/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/orchestrator.d.ts +99 -12
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +172 -161
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/tier-scheduler.js +7 -17
- 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 +14 -10
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +39 -51
- package/dist/lib/external/mcp/handlers/bootstrap-internal.d.ts +2 -0
- package/dist/lib/external/mcp/handlers/bootstrap-internal.js +115 -82
- package/dist/lib/external/mcp/handlers/consolidated.d.ts +4 -4
- package/dist/lib/external/mcp/handlers/consolidated.js +107 -332
- package/dist/lib/external/mcp/handlers/dimension-complete-external.js +69 -1
- package/dist/lib/external/mcp/handlers/evolve-external.d.ts +54 -0
- package/dist/lib/external/mcp/handlers/evolve-external.js +226 -0
- package/dist/lib/external/mcp/handlers/knowledge.js +26 -2
- 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/knowledge.js +122 -1
- package/dist/lib/http/routes/modules.js +25 -3
- package/dist/lib/http/routes/panorama.js +16 -4
- 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.js +55 -0
- package/dist/lib/injection/ServiceMap.d.ts +8 -1
- package/dist/lib/injection/modules/KnowledgeModule.js +15 -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 +85 -0
- package/dist/lib/service/cleanup/CleanupService.js +324 -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/ConfidenceRouter.js +1 -1
- package/dist/lib/service/knowledge/KnowledgeService.d.ts +11 -1
- package/dist/lib/service/knowledge/KnowledgeService.js +44 -4
- package/dist/lib/service/knowledge/RecipeProductionGateway.d.ts +225 -0
- package/dist/lib/service/knowledge/RecipeProductionGateway.js +384 -0
- package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +3 -2
- package/dist/lib/service/panorama/DimensionAnalyzer.js +15 -140
- 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/shared/schemas/common.d.ts +4 -4
- package/dist/lib/shared/schemas/http-requests.d.ts +12 -1
- package/dist/lib/shared/schemas/http-requests.js +8 -0
- 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 +131 -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
|
@@ -13,28 +13,115 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @module pipeline/orchestrator
|
|
15
15
|
*/
|
|
16
|
+
import type { DimensionDef } from '#types/project-snapshot.js';
|
|
17
|
+
import type { PipelineFillView } from '#types/snapshot-views.js';
|
|
16
18
|
import { clearCheckpoints } from './checkpoint.js';
|
|
17
|
-
/**
|
|
19
|
+
/** Singleton properties accessed by orchestrator */
|
|
20
|
+
interface OrchestratorSingletons {
|
|
21
|
+
aiProvider?: {
|
|
22
|
+
name?: string;
|
|
23
|
+
model?: string;
|
|
24
|
+
supportsEmbedding?: () => boolean;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
} | null;
|
|
27
|
+
_embedProvider?: {
|
|
28
|
+
embed?: (text: string) => Promise<number[]>;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
} | null;
|
|
31
|
+
_fileCache?: BootstrapFileEntry[] | null;
|
|
32
|
+
_projectRoot?: string;
|
|
33
|
+
_config?: Record<string, unknown>;
|
|
34
|
+
_lang?: string | null;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
/** Services orchestrator accesses via container.get() */
|
|
38
|
+
interface OrchestratorServiceKeys {
|
|
39
|
+
agentFactory: AgentFactoryLike;
|
|
40
|
+
bootstrapTaskManager: TaskManagerLike;
|
|
41
|
+
database: any;
|
|
42
|
+
}
|
|
43
|
+
/** Extended DI container shape for orchestrator */
|
|
18
44
|
interface OrchestratorContainer {
|
|
45
|
+
get<K extends keyof OrchestratorServiceKeys>(name: K): OrchestratorServiceKeys[K];
|
|
19
46
|
get(name: string): any;
|
|
20
|
-
|
|
47
|
+
singletons: OrchestratorSingletons;
|
|
48
|
+
buildProjectGraph?(projectRoot: string, options?: Record<string, unknown>): Promise<ProjectGraphLike | null>;
|
|
49
|
+
[key: string]: unknown;
|
|
21
50
|
}
|
|
22
|
-
/**
|
|
23
|
-
interface
|
|
24
|
-
|
|
25
|
-
|
|
51
|
+
/** ProjectGraph minimal shape */
|
|
52
|
+
interface ProjectGraphLike {
|
|
53
|
+
getOverview(): {
|
|
54
|
+
totalClasses: number;
|
|
55
|
+
totalProtocols: number;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
};
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
}
|
|
60
|
+
/** Bootstrap file entry */
|
|
61
|
+
interface BootstrapFileEntry {
|
|
62
|
+
name: string;
|
|
63
|
+
path: string;
|
|
64
|
+
relativePath: string;
|
|
65
|
+
content: string;
|
|
66
|
+
targetName?: string;
|
|
67
|
+
}
|
|
68
|
+
/** Task manager minimal shape */
|
|
69
|
+
interface TaskManagerLike {
|
|
70
|
+
isSessionValid(sessionId: string): boolean;
|
|
71
|
+
emitProgress?(event: string, data: Record<string, unknown>): void;
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
}
|
|
74
|
+
/** Agent factory minimal shape */
|
|
75
|
+
interface AgentFactoryLike {
|
|
76
|
+
createRuntime(preset: string, overrides?: Record<string, unknown>): AgentRuntimeLike;
|
|
77
|
+
createContextWindow(opts?: {
|
|
78
|
+
isSystem?: boolean;
|
|
79
|
+
}): unknown;
|
|
80
|
+
[key: string]: unknown;
|
|
81
|
+
}
|
|
82
|
+
/** Agent runtime minimal shape */
|
|
83
|
+
interface AgentRuntimeLike {
|
|
84
|
+
execute(message: unknown, opts?: Record<string, unknown>): Promise<AgentResultLike>;
|
|
85
|
+
setFileCache(files: unknown[] | null): void;
|
|
86
|
+
aiProvider: {
|
|
87
|
+
name?: string;
|
|
88
|
+
model?: string;
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
};
|
|
91
|
+
[key: string]: unknown;
|
|
92
|
+
}
|
|
93
|
+
/** Agent execution result */
|
|
94
|
+
interface AgentResultLike {
|
|
95
|
+
reply?: string;
|
|
96
|
+
toolCalls?: ToolCallRecord[];
|
|
97
|
+
tokenUsage?: {
|
|
98
|
+
input: number;
|
|
99
|
+
output: number;
|
|
100
|
+
};
|
|
101
|
+
phases?: Record<string, {
|
|
102
|
+
reply?: string;
|
|
103
|
+
artifact?: Record<string, any>;
|
|
104
|
+
[key: string]: any;
|
|
105
|
+
}>;
|
|
106
|
+
degraded?: boolean;
|
|
107
|
+
[key: string]: unknown;
|
|
26
108
|
}
|
|
27
|
-
/**
|
|
28
|
-
interface
|
|
29
|
-
|
|
30
|
-
|
|
109
|
+
/** Tool call record from runtime */
|
|
110
|
+
interface ToolCallRecord {
|
|
111
|
+
tool?: string;
|
|
112
|
+
name?: string;
|
|
113
|
+
args?: Record<string, unknown>;
|
|
114
|
+
params?: Record<string, unknown>;
|
|
115
|
+
result?: unknown;
|
|
116
|
+
[key: string]: unknown;
|
|
31
117
|
}
|
|
32
118
|
/**
|
|
33
119
|
* fillDimensionsV3 — v3.0 AI-First 维度填充管线
|
|
34
120
|
*
|
|
35
|
-
* @param
|
|
121
|
+
* @param view PipelineFillView — 从 handler 传入的类型化视图
|
|
122
|
+
* @param dimensions 当前运行的维度列表(rescan 可能是 gap 子集)
|
|
36
123
|
*/
|
|
37
|
-
export declare function fillDimensionsV3(
|
|
124
|
+
export declare function fillDimensionsV3(view: PipelineFillView, dimensions: DimensionDef[]): Promise<void>;
|
|
38
125
|
/**
|
|
39
126
|
* 清除增量 Bootstrap 快照 — 供 bootstrapKnowledge 在手动冷启动时调用
|
|
40
127
|
* @param ctx { container, logger }
|
|
@@ -23,26 +23,25 @@ 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 { runNoAiFallback } from './noAiFallback.js';
|
|
35
35
|
import { TierScheduler } from './tier-scheduler.js';
|
|
36
36
|
const logger = Logger.getInstance();
|
|
37
37
|
// ──────────────────────────────────────────────────────────────────
|
|
38
38
|
// Panorama Context for strategyContext injection (M1 §5.2)
|
|
39
39
|
// ──────────────────────────────────────────────────────────────────
|
|
40
40
|
/**
|
|
41
|
-
* 从
|
|
41
|
+
* 从 panoramaResult 提取维度级全景上下文
|
|
42
42
|
* 注入 strategyContext.panorama,使 Agent 获得模块角色/层级/耦合/空白区信息
|
|
43
43
|
*/
|
|
44
|
-
function buildPanoramaContext(
|
|
45
|
-
const panoramaResult = fillContext.panoramaResult;
|
|
44
|
+
function buildPanoramaContext(panoramaResult, _dimConfig) {
|
|
46
45
|
if (!panoramaResult) {
|
|
47
46
|
return null;
|
|
48
47
|
}
|
|
@@ -87,16 +86,35 @@ function buildPanoramaContext(fillContext, _dimConfig) {
|
|
|
87
86
|
/**
|
|
88
87
|
* fillDimensionsV3 — v3.0 AI-First 维度填充管线
|
|
89
88
|
*
|
|
90
|
-
* @param
|
|
89
|
+
* @param view PipelineFillView — 从 handler 传入的类型化视图
|
|
90
|
+
* @param dimensions 当前运行的维度列表(rescan 可能是 gap 子集)
|
|
91
91
|
*/
|
|
92
|
-
export async function fillDimensionsV3(
|
|
93
|
-
const {
|
|
94
|
-
|
|
92
|
+
export async function fillDimensionsV3(view, dimensions) {
|
|
93
|
+
const { snapshot, projectRoot } = view;
|
|
94
|
+
const ctx = view.ctx;
|
|
95
|
+
// 从 snapshot 提取 orchestrator 所需字段
|
|
96
|
+
const depGraphData = snapshot.dependencyGraph;
|
|
97
|
+
const guardAudit = snapshot.guardAudit;
|
|
98
|
+
const primaryLang = snapshot.language.primaryLang ?? 'unknown';
|
|
99
|
+
const astProjectSummary = snapshot.ast;
|
|
100
|
+
const incrementalPlan = snapshot.incrementalPlan;
|
|
101
|
+
const panoramaResult = snapshot.panorama;
|
|
102
|
+
const callGraphResult = snapshot.callGraph;
|
|
103
|
+
const existingRecipes = view.existingRecipes ?? null;
|
|
104
|
+
const targetFileMap = view.targetFileMap;
|
|
105
|
+
// 从 ctx 获取运行时服务
|
|
106
|
+
let taskManager = null;
|
|
107
|
+
try {
|
|
108
|
+
taskManager = ctx.container.get('bootstrapTaskManager');
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
/* not available */
|
|
112
|
+
}
|
|
113
|
+
const sessionId = view.bootstrapSession?.id ?? '';
|
|
95
114
|
const isIncremental = incrementalPlan?.canIncremental && incrementalPlan?.mode === 'incremental';
|
|
96
115
|
const emitter = new BootstrapEventEmitter(ctx.container);
|
|
97
116
|
logger.info(`[Insight-v3] ═══ fillDimensionsV3 entered — ${isIncremental ? 'INCREMENTAL' : 'FULL'} pipeline`);
|
|
98
|
-
let allFiles =
|
|
99
|
-
fillContext.allFiles = null;
|
|
117
|
+
let allFiles = snapshot.allFiles;
|
|
100
118
|
// ═══════════════════════════════════════════════════════════
|
|
101
119
|
// Step 0: AI 可用性检查 (v7.2: 使用 AgentFactory)
|
|
102
120
|
// ═══════════════════════════════════════════════════════════
|
|
@@ -113,134 +131,12 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
113
131
|
/* not available */
|
|
114
132
|
}
|
|
115
133
|
if (!agentFactory) {
|
|
116
|
-
logger.
|
|
134
|
+
logger.error('[Insight-v3] AI Provider not available — bootstrap requires AI');
|
|
117
135
|
emitter.emitProgress('bootstrap:ai-unavailable', {
|
|
118
|
-
message: 'AI
|
|
136
|
+
message: 'AI Provider 不可用,Bootstrap 需要 AI 才能运行。请先配置 AI Provider(如 OpenAI、Anthropic 等)后重试。',
|
|
119
137
|
});
|
|
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
|
-
}
|
|
138
|
+
for (const dim of dimensions) {
|
|
139
|
+
emitter.emitDimensionComplete(dim.id, { type: 'skipped', reason: 'ai-unavailable' });
|
|
244
140
|
}
|
|
245
141
|
return;
|
|
246
142
|
}
|
|
@@ -249,10 +145,11 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
249
145
|
// ═══════════════════════════════════════════════════════════
|
|
250
146
|
let projectGraph = null;
|
|
251
147
|
try {
|
|
252
|
-
projectGraph =
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
148
|
+
projectGraph =
|
|
149
|
+
(await ctx.container.buildProjectGraph?.(projectRoot, {
|
|
150
|
+
maxFiles: 500,
|
|
151
|
+
timeoutMs: 15_000,
|
|
152
|
+
})) ?? null;
|
|
256
153
|
if (projectGraph) {
|
|
257
154
|
const overview = projectGraph.getOverview();
|
|
258
155
|
logger.info(`[Insight-v3] ProjectGraph: ${overview.totalClasses} classes, ${overview.totalProtocols} protocols (${overview.buildTimeMs}ms)`);
|
|
@@ -278,11 +175,11 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
278
175
|
projectName: projectInfo.name,
|
|
279
176
|
primaryLang: projectInfo.lang,
|
|
280
177
|
fileCount: projectInfo.fileCount,
|
|
281
|
-
targetCount: Object.keys(
|
|
282
|
-
modules: Object.keys(
|
|
283
|
-
depGraph: depGraphData
|
|
284
|
-
astMetrics: astProjectSummary?.projectMetrics
|
|
285
|
-
guardSummary: guardAudit?.summary
|
|
178
|
+
targetCount: Object.keys(targetFileMap || {}).length,
|
|
179
|
+
modules: Object.keys(targetFileMap || {}),
|
|
180
|
+
depGraph: depGraphData ?? undefined,
|
|
181
|
+
astMetrics: astProjectSummary?.projectMetrics ?? undefined,
|
|
182
|
+
guardSummary: guardAudit?.summary ?? undefined,
|
|
286
183
|
});
|
|
287
184
|
// v4.0: SessionStore — 替代 EpisodicMemory + ToolResultCache
|
|
288
185
|
// v5.0: 增量模式下从快照恢复已完成维度的记忆
|
|
@@ -304,7 +201,7 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
304
201
|
projectName: projectInfo.name,
|
|
305
202
|
primaryLang: projectInfo.lang,
|
|
306
203
|
fileCount: projectInfo.fileCount,
|
|
307
|
-
modules: Object.keys(
|
|
204
|
+
modules: Object.keys(targetFileMap || {}),
|
|
308
205
|
});
|
|
309
206
|
}
|
|
310
207
|
// v4.1: PersistentMemory — 项目级永久语义记忆 (Tier 3)
|
|
@@ -414,6 +311,36 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
414
311
|
// ── 跨维度去重集合 (实例级持久化,等效旧 ChatAgent.#globalSubmittedTitles/Patterns) ──
|
|
415
312
|
const globalSubmittedTitles = new Set();
|
|
416
313
|
const globalSubmittedPatterns = new Set();
|
|
314
|
+
// ── Rescan 模式: 预种已有 recipe 标题到去重集合,防止重复创建 ──
|
|
315
|
+
const existingRecipesList = existingRecipes;
|
|
316
|
+
if (existingRecipesList && existingRecipesList.length > 0) {
|
|
317
|
+
for (const r of existingRecipesList) {
|
|
318
|
+
// ★ 只预种 healthy 标题,decaying 的允许被替代
|
|
319
|
+
if (r.title && r.status !== 'decaying') {
|
|
320
|
+
globalSubmittedTitles.add(r.title.toLowerCase().trim());
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
logger.info(`[Insight-v3] Rescan mode: seeded ${globalSubmittedTitles.size} existing recipe titles into dedup set`);
|
|
324
|
+
}
|
|
325
|
+
// 构建 rescanContext 供 Analyst/Producer prompt 使用(区分 healthy/decaying)
|
|
326
|
+
const rescanContext = existingRecipesList
|
|
327
|
+
? {
|
|
328
|
+
// healthy 列表 — 告诉 Agent "不要重复"
|
|
329
|
+
existingRecipes: existingRecipesList.filter((r) => r.status !== 'decaying'),
|
|
330
|
+
// decaying 列表 — 告诉 Agent "可以替换"
|
|
331
|
+
decayingRecipes: existingRecipesList.filter((r) => r.status === 'decaying'),
|
|
332
|
+
// trigger 仍全部占用(含 decaying)
|
|
333
|
+
occupiedTriggers: existingRecipesList.map((r) => r.trigger).filter(Boolean),
|
|
334
|
+
coverageByDim: existingRecipesList.reduce((acc, r) => {
|
|
335
|
+
// 只有 healthy 计入覆盖
|
|
336
|
+
if (r.status !== 'decaying') {
|
|
337
|
+
const dim = r.knowledgeType || 'unknown';
|
|
338
|
+
acc[dim] = (acc[dim] || 0) + 1;
|
|
339
|
+
}
|
|
340
|
+
return acc;
|
|
341
|
+
}, {}),
|
|
342
|
+
}
|
|
343
|
+
: null;
|
|
417
344
|
/** 执行单个维度: Analyst → Gate → Producer */
|
|
418
345
|
async function executeDimension(dimId) {
|
|
419
346
|
// v5.0: 增量模式 — 跳过未受影响的维度 (使用历史 EpisodicMemory)
|
|
@@ -530,15 +457,22 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
530
457
|
: !dimConfig.skillWorthy || dimConfig.dualOutput;
|
|
531
458
|
// ── 获取 Preset 的标准 stages 配置作为基础 ──
|
|
532
459
|
const presetStages = PRESETS.insight.strategy.stages;
|
|
460
|
+
const evolutionPresetStages = PRESETS.evolution.strategy.stages;
|
|
461
|
+
// ── 判断当前维度是否有现有 Recipe(按维度过滤后) ──
|
|
462
|
+
const dimExistingRecipes = [
|
|
463
|
+
...(rescanContext?.existingRecipes?.filter((r) => r.knowledgeType === dimId) ?? []),
|
|
464
|
+
...(rescanContext?.decayingRecipes?.filter((r) => r.knowledgeType === dimId) ?? []),
|
|
465
|
+
];
|
|
466
|
+
const hasExistingRecipes = dimExistingRecipes.length > 0;
|
|
533
467
|
// ── 构建 per-dimension 的 stages ──
|
|
534
468
|
// NOTE: onToolCall 不再注入 ac.recordToolCall — ToolExecutionPipeline 的
|
|
535
469
|
// traceRecord 中间件已通过 loopCtx.trace 统一记录,避免同一 AC 上双重记录。
|
|
536
470
|
const analyzeStage = {
|
|
537
471
|
...presetStages[0],
|
|
538
472
|
};
|
|
473
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- pipeline stage shapes from PRESETS; needs PipelineStage interface (T4)
|
|
539
474
|
let stages;
|
|
540
475
|
if (needsCandidates) {
|
|
541
|
-
// 候选维度: Analyze→QualityGate→Produce→RejectionGate
|
|
542
476
|
const produceStage = {
|
|
543
477
|
...presetStages[2],
|
|
544
478
|
promptBuilder: (ctx) => {
|
|
@@ -546,12 +480,26 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
546
480
|
return presetStages[2].promptBuilder?.(ctx);
|
|
547
481
|
},
|
|
548
482
|
};
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
483
|
+
if (hasExistingRecipes) {
|
|
484
|
+
// 当前维度有旧 Recipe: Evolve→EvolutionGate→Analyze→QualityGate→Produce→RejectionGate
|
|
485
|
+
stages = [
|
|
486
|
+
evolutionPresetStages[0], // evolve
|
|
487
|
+
evolutionPresetStages[1], // evolution_gate
|
|
488
|
+
analyzeStage,
|
|
489
|
+
presetStages[1], // quality_gate
|
|
490
|
+
produceStage,
|
|
491
|
+
presetStages[3], // rejection_gate
|
|
492
|
+
];
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
// 当前维度无旧 Recipe: Analyze→QualityGate→Produce→RejectionGate
|
|
496
|
+
stages = [
|
|
497
|
+
analyzeStage,
|
|
498
|
+
presetStages[1], // quality_gate
|
|
499
|
+
produceStage,
|
|
500
|
+
presetStages[3], // rejection_gate
|
|
501
|
+
];
|
|
502
|
+
}
|
|
555
503
|
}
|
|
556
504
|
else {
|
|
557
505
|
// Skill-only 维度: 仅 Analyze
|
|
@@ -585,7 +533,51 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
585
533
|
activeContext: memoryCoordinator.getActiveContext(analystScopeId),
|
|
586
534
|
outputType: dimConfig.outputType || 'analysis',
|
|
587
535
|
// §M1: Panorama 全景上下文 (Phase 1.8 数据注入)
|
|
588
|
-
panorama: buildPanoramaContext(
|
|
536
|
+
panorama: buildPanoramaContext(panoramaResult, dimConfig),
|
|
537
|
+
// §ES: Evidence Starters — 从 Phase 1-4 数据提取维度级证据启发
|
|
538
|
+
evidenceStarters: buildEvidenceStarters(dimConfig, {
|
|
539
|
+
astData: astProjectSummary,
|
|
540
|
+
guardAudit,
|
|
541
|
+
depGraphData,
|
|
542
|
+
callGraphResult,
|
|
543
|
+
panoramaResult,
|
|
544
|
+
}),
|
|
545
|
+
// §R1: Rescan 模式 — 已有 recipe 上下文 (避免重复分析/创建)
|
|
546
|
+
rescanContext: rescanContext
|
|
547
|
+
? {
|
|
548
|
+
existingRecipes: rescanContext.existingRecipes.filter((r) => r.knowledgeType === dimId),
|
|
549
|
+
decayingRecipes: rescanContext.decayingRecipes.filter((r) => r.knowledgeType === dimId),
|
|
550
|
+
occupiedTriggers: rescanContext.occupiedTriggers,
|
|
551
|
+
gap: Math.max(0, 5 - (rescanContext.coverageByDim[dimId] || 0)),
|
|
552
|
+
existing: rescanContext.coverageByDim[dimId] || 0,
|
|
553
|
+
}
|
|
554
|
+
: null,
|
|
555
|
+
// §EVO: Evolution Stage — 当前维度全部现有 Recipe(healthy + decaying),附带 audit hint
|
|
556
|
+
existingRecipes: dimExistingRecipes.map((r) => ({
|
|
557
|
+
id: r.id,
|
|
558
|
+
title: r.title,
|
|
559
|
+
trigger: r.trigger,
|
|
560
|
+
content: r.content,
|
|
561
|
+
sourceRefs: r.sourceRefs,
|
|
562
|
+
auditHint: 'auditScore' in r && r.auditScore != null
|
|
563
|
+
? {
|
|
564
|
+
relevanceScore: r.auditScore,
|
|
565
|
+
verdict: r.status === 'decaying' ? 'decay' : 'watch',
|
|
566
|
+
evidence: r.auditEvidence ?? {},
|
|
567
|
+
decayReasons: r.decayReason
|
|
568
|
+
? [String(r.decayReason)]
|
|
569
|
+
: [],
|
|
570
|
+
}
|
|
571
|
+
: null,
|
|
572
|
+
})),
|
|
573
|
+
// Evolution 上下文字段 — buildEvolverPrompt 直接从 strategyContext 读取
|
|
574
|
+
dimensionId: dimId,
|
|
575
|
+
dimensionLabel: dimConfig.label,
|
|
576
|
+
projectOverview: {
|
|
577
|
+
primaryLang: primaryLang || projectInfo.lang || 'unknown',
|
|
578
|
+
fileCount: projectInfo.fileCount || 0,
|
|
579
|
+
modules: Object.keys(targetFileMap || {}),
|
|
580
|
+
},
|
|
589
581
|
// ── 引擎增强参数 (PipelineStrategy → reactLoop 透传) ──
|
|
590
582
|
contextWindow: agentFactory.createContextWindow({ isSystem: true }),
|
|
591
583
|
// B1 fix: 分析阶段使用 analyst 策略 (SCAN→EXPLORE→VERIFY→SUMMARIZE)
|
|
@@ -609,7 +601,7 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
609
601
|
};
|
|
610
602
|
// ── 执行 ──
|
|
611
603
|
// 外层超时 = 安全网 (各阶段已有独立超时: Analyst 300s + Producer 180s + 硬缓冲 60s)
|
|
612
|
-
const outerTimeoutMs =
|
|
604
|
+
const outerTimeoutMs = 3_600_000; // 1 小时——维度分析本身耗时长
|
|
613
605
|
const runResult = await Promise.race([
|
|
614
606
|
runtime.execute(message, { strategyContext }),
|
|
615
607
|
new Promise((_, reject) => setTimeout(() => reject(new Error(`Bootstrap runtime timeout for "${dimId}"`)), outerTimeoutMs)),
|
|
@@ -686,6 +678,26 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
686
678
|
};
|
|
687
679
|
candidateResults.created += producerResult.candidateCount;
|
|
688
680
|
dimensionCandidates[dimId] = { analysisReport, producerResult };
|
|
681
|
+
// ── Producer 阶段详细日志 ──
|
|
682
|
+
if (needsCandidates) {
|
|
683
|
+
const producerToolCalls = produceResult?.toolCalls || [];
|
|
684
|
+
const producerToolNames = producerToolCalls.map((tc) => tc?.tool || tc?.name || 'unknown');
|
|
685
|
+
const toolBreakdown = {};
|
|
686
|
+
for (const name of producerToolNames) {
|
|
687
|
+
toolBreakdown[name] = (toolBreakdown[name] || 0) + 1;
|
|
688
|
+
}
|
|
689
|
+
const breakdownStr = Object.entries(toolBreakdown)
|
|
690
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
691
|
+
.join(', ');
|
|
692
|
+
logger.info(`[Producer] "${dimId}": submitted=${submitCalls.length}, accepted=${successCount}, rejected=${rejectedCount}, ` +
|
|
693
|
+
`producerToolCalls=${producerToolCalls.length} (${breakdownStr || 'none'}), ` +
|
|
694
|
+
`analysisInput=${analysisText.length} chars`);
|
|
695
|
+
if (successCount === 0 && submitCalls.length === 0) {
|
|
696
|
+
logger.warn(`[Producer] "${dimId}": ⚠ Producer 未提交任何候选。` +
|
|
697
|
+
`分析文本=${analysisText.length} chars, findings=${(analysisReport.findings || []).length}, ` +
|
|
698
|
+
`producerIterations=${producerToolCalls.length}, degraded=${runResult?.degraded || false}`);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
689
701
|
// ── Memory Update ──
|
|
690
702
|
const ac = memoryCoordinator.getActiveContext(analystScopeId);
|
|
691
703
|
const distilled = ac
|
|
@@ -866,9 +878,9 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
866
878
|
logger.info(`[Insight-v3] Memory stats: ${emStats.completedDimensions} dims, ` +
|
|
867
879
|
`${emStats.totalFindings} findings, ${emStats.referencedFiles} files, ` +
|
|
868
880
|
`${emStats.crossReferences} cross-refs, ${emStats.tierReflections} reflections`);
|
|
869
|
-
if (emStats.
|
|
870
|
-
logger.info(`[Insight-v3] Cache stats: ${emStats.
|
|
871
|
-
`${emStats.
|
|
881
|
+
if (emStats.cache) {
|
|
882
|
+
logger.info(`[Insight-v3] Cache stats: ${emStats.cache.hitRate} hit rate, ` +
|
|
883
|
+
`${emStats.cache.searchCacheSize} searches, ${emStats.cache.fileCacheSize} files`);
|
|
872
884
|
}
|
|
873
885
|
}
|
|
874
886
|
else {
|
|
@@ -910,9 +922,8 @@ export async function fillDimensionsV3(fillContext) {
|
|
|
910
922
|
const referencedFiles = dimData.analysisReport.referencedFiles || [];
|
|
911
923
|
// 从 SessionStore 获取结构化发现,供 Skill 生成使用
|
|
912
924
|
const dimReport = sessionStore.getDimensionReport(dim.id);
|
|
913
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- SessionStore Finding type varies
|
|
914
925
|
const keyFindings = (dimReport?.findings || [])
|
|
915
|
-
.sort((a, b) => (b.importance || 5) - (a.importance || 5))
|
|
926
|
+
.sort((a, b) => (Number(b.importance) || 5) - (Number(a.importance) || 5))
|
|
916
927
|
.slice(0, 10)
|
|
917
928
|
.map((f) => String(f.finding || ''));
|
|
918
929
|
// 当 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
|
// ──────────────────────────────────────────────────────────────────
|