autosnippet 3.3.4 → 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/README.md +174 -83
- package/config/constitution.yaml +2 -0
- 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.d.ts +5 -1
- package/dist/lib/cli/KnowledgeSyncService.js +6 -3
- 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/domain/knowledge/values/Stats.d.ts +1 -1
- package/dist/lib/domain/knowledge/values/Stats.js +2 -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/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 +115 -162
- 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 +60 -3
- 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/InfraModule.js +4 -1
- package/dist/lib/injection/modules/KnowledgeModule.js +38 -1
- package/dist/lib/repository/evolution/ProposalRepository.d.ts +99 -0
- package/dist/lib/repository/evolution/ProposalRepository.js +255 -0
- 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 +22 -4
- package/dist/lib/service/bootstrap/UiStartupTasks.js +73 -5
- 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/DecayDetector.d.ts +4 -3
- package/dist/lib/service/evolution/DecayDetector.js +97 -22
- package/dist/lib/service/evolution/KnowledgeMetabolism.d.ts +4 -2
- package/dist/lib/service/evolution/KnowledgeMetabolism.js +29 -2
- package/dist/lib/service/evolution/ProposalExecutor.d.ts +66 -0
- package/dist/lib/service/evolution/ProposalExecutor.js +424 -0
- 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/StagingManager.js +5 -3
- 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/guard/GuardCrossFileChecks.js +2 -0
- package/dist/lib/service/guard/ReverseGuard.d.ts +1 -1
- package/dist/lib/service/guard/ReverseGuard.js +32 -2
- 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/knowledge/SourceRefReconciler.d.ts +2 -0
- package/dist/lib/service/knowledge/SourceRefReconciler.js +48 -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 +33 -2
- package/dist/lib/shared/schemas/mcp-tools.js +42 -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
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module insight-analyst
|
|
14
14
|
*/
|
|
15
|
-
import { getDimensionSOP } from '#
|
|
15
|
+
import { getDimensionSOP } from '#domain/dimension/DimensionSop.js';
|
|
16
16
|
// ──────────────────────────────────────────────────────────────────
|
|
17
17
|
// System Prompt — Analyst 专用 (~100 tokens)
|
|
18
18
|
// ──────────────────────────────────────────────────────────────────
|
|
@@ -39,7 +39,10 @@ export const ANALYST_SYSTEM_PROMPT = `你是一位高级软件架构师,正在
|
|
|
39
39
|
- **结构化查询优先**: get_class_hierarchy / get_class_info 比文本搜索更精确高效
|
|
40
40
|
|
|
41
41
|
## 输出要求
|
|
42
|
-
|
|
42
|
+
输出你的分析发现,包括具体的文件完整相对路径(从项目根目录开始)和行号。
|
|
43
|
+
每个文件引用格式: (来源: Full/Relative/Path/FileName.ext:行号)
|
|
44
|
+
禁止只写文件名,必须写从项目根开始的完整路径。
|
|
45
|
+
标注每个发现所属的模块/包名。
|
|
43
46
|
用自然语言描述你的理解,不需要特定格式。`;
|
|
44
47
|
// ──────────────────────────────────────────────────────────────────
|
|
45
48
|
// Analyst 可用工具白名单 — 只做探索,不做提交
|
|
@@ -77,13 +80,10 @@ export const ANALYST_BUDGET = {
|
|
|
77
80
|
softSubmitLimit: 0,
|
|
78
81
|
idleRoundsToExit: 2,
|
|
79
82
|
};
|
|
80
|
-
// ──────────────────────────────────────────────────────────────────
|
|
81
|
-
// 维度 Prompt 模板 (9 段式)
|
|
82
|
-
// ──────────────────────────────────────────────────────────────────
|
|
83
83
|
/**
|
|
84
84
|
* 构建 Analyst Prompt
|
|
85
85
|
*
|
|
86
|
-
*
|
|
86
|
+
* 12 段结构:
|
|
87
87
|
* §1 任务描述
|
|
88
88
|
* §2 维度指引
|
|
89
89
|
* §3 SOP (分析步骤 + 常见错误)
|
|
@@ -93,6 +93,9 @@ export const ANALYST_BUDGET = {
|
|
|
93
93
|
* §7 Tier Reflection 洞察
|
|
94
94
|
* §8 历史语义记忆 (Tier 3)
|
|
95
95
|
* §9 代码实体图谱 (Phase E)
|
|
96
|
+
* §ES 分析起点证据 (Phase 1-4 Evidence Starters)
|
|
97
|
+
* §M1 全景上下文 (Panorama Phase 1.8)
|
|
98
|
+
* §10 Rescan 已有知识上下文
|
|
96
99
|
*
|
|
97
100
|
* @param dimConfig 维度配置 { id, label, guide, focusKeywords, outputType }
|
|
98
101
|
* @param projectInfo { name, lang, fileCount }
|
|
@@ -100,8 +103,12 @@ export const ANALYST_BUDGET = {
|
|
|
100
103
|
* @param [episodicMemory] SessionStore 实例 (v4.0 增强上下文)
|
|
101
104
|
* @param [semanticMemory] PersistentMemory 实例 (v4.1 历史记忆)
|
|
102
105
|
* @param [codeEntityGraph] CodeEntityGraph 实例 (Phase E 代码实体图谱)
|
|
106
|
+
* @param [rescanContext] Rescan 已有知识上下文 (增量扫描时注入)
|
|
107
|
+
* @param [panorama] 全景上下文 — 模块角色/层级/耦合/空白区 (Phase 1.8)
|
|
108
|
+
* @param [evidenceStarters] Phase 1-4 证据启发 — 维度级分析起点
|
|
109
|
+
* @param [evolutionResult] Evolution Stage 产出 — 避免重复分析已处理的 Recipe
|
|
103
110
|
*/
|
|
104
|
-
export async function buildAnalystPrompt(dimConfig, projectInfo, dimensionContext, episodicMemory, semanticMemory, codeEntityGraph) {
|
|
111
|
+
export async function buildAnalystPrompt(dimConfig, projectInfo, dimensionContext, episodicMemory, semanticMemory, codeEntityGraph, rescanContext, panorama, evidenceStarters, evolutionResult) {
|
|
105
112
|
const parts = [];
|
|
106
113
|
// §1 任务描述
|
|
107
114
|
parts.push(`分析项目 ${projectInfo.name} (${projectInfo.lang}, ${projectInfo.fileCount} 个文件) 的 ${dimConfig.label}。`);
|
|
@@ -144,17 +151,21 @@ export async function buildAnalystPrompt(dimConfig, projectInfo, dimensionContex
|
|
|
144
151
|
const outputType = dimConfig.outputType || 'analysis';
|
|
145
152
|
const needsCandidates = outputType === 'dual' || outputType === 'candidate';
|
|
146
153
|
const depthHint = needsCandidates
|
|
147
|
-
? '
|
|
154
|
+
? '你的分析将被转化为知识候选,请确保每个发现都有足够的代码证据和文件引用。按实际发现总结,有几个独立知识点就写几个。'
|
|
148
155
|
: '';
|
|
149
156
|
parts.push(`请将分析组织成结构化段落,包含:
|
|
150
|
-
1. 在哪些文件/类中发现 (
|
|
157
|
+
1. 在哪些文件/类中发现 (写出从项目根目录开始的完整相对路径+行号,如 Packages/ModuleName/Sources/.../FileName.swift:42)
|
|
151
158
|
2. 具体的实现方式和代码特征
|
|
152
159
|
3. 为什么选择这种方式(设计意图)
|
|
153
160
|
4. 统计数据 (如数量、占比)
|
|
161
|
+
5. 所属模块/包名(特别是来自本地子包的发现)
|
|
154
162
|
|
|
155
|
-
每个关键发现用编号列表呈现,引用 3
|
|
163
|
+
每个关键发现用编号列表呈现,引用 3 个以上具体文件(完整相对路径)。
|
|
164
|
+
禁止只写文件名(如 NetworkClient.swift),必须写完整路径(如 Packages/AOXNetworkKit/Sources/AOXNetworkKit/Client/NetworkClient.swift:42)。
|
|
156
165
|
${depthHint}
|
|
157
|
-
重要: 务必使用 read_project_file
|
|
166
|
+
重要: 务必使用 read_project_file 阅读代码确认,不要假设文件存在。引用的每个文件路径都必须是你亲眼看到的。
|
|
167
|
+
【跨维度去重】只分析属于当前维度视角的内容。不要将其他维度的知识点混入本维度来充数。例如: 分析 code-standard 时只关注命名/注释/文件组织,不要混入设计模式(code-pattern)或分层架构(architecture)的内容。如果某个发现与多个维度相关,则只从当前维度的核心视角分析,避免与其他维度产生重叠。
|
|
168
|
+
【本地子包覆盖】如果项目有本地子包/模块(如 Packages/ 目录下的包),必须同时分析其内部实现,不得仅看主项目对其的调用。`);
|
|
158
169
|
// §5 前序上下文提示
|
|
159
170
|
parts.push('可以调用 get_previous_analysis 获取前序维度的分析结果,避免重复分析。');
|
|
160
171
|
parts.push('使用 note_finding 工具记录关键发现到工作记忆,确保重要信息不会在后期被遗忘。');
|
|
@@ -218,5 +229,94 @@ ${depthHint}
|
|
|
218
229
|
/* CodeEntityGraph context failed, non-critical */
|
|
219
230
|
}
|
|
220
231
|
}
|
|
232
|
+
// §ES: 分析起点证据 (Phase 1-4 Evidence Starters)
|
|
233
|
+
if (evidenceStarters && Object.keys(evidenceStarters).length > 0) {
|
|
234
|
+
const esLines = ['## 📊 分析起点 (Phase 1-4 自动检测)'];
|
|
235
|
+
esLines.push('以下是自动化分析阶段检测到的与本维度相关的信号,可作为分析起点:');
|
|
236
|
+
// 按 strength 降序排列,取前 6 个最强信号
|
|
237
|
+
const sorted = Object.entries(evidenceStarters)
|
|
238
|
+
.sort(([, a], [, b]) => (b.strength ?? 50) - (a.strength ?? 50))
|
|
239
|
+
.slice(0, 6);
|
|
240
|
+
for (const [key, entry] of sorted) {
|
|
241
|
+
const strengthBadge = (entry.strength ?? 50) >= 75 ? '⚠️' : '📝';
|
|
242
|
+
esLines.push(`${strengthBadge} **${key}**: ${entry.hint}`);
|
|
243
|
+
if (entry.data) {
|
|
244
|
+
const dataStr = Array.isArray(entry.data)
|
|
245
|
+
? entry.data
|
|
246
|
+
.slice(0, 5)
|
|
247
|
+
.map((d) => ` - ${typeof d === 'string' ? d : JSON.stringify(d)}`)
|
|
248
|
+
.join('\n')
|
|
249
|
+
: typeof entry.data === 'string'
|
|
250
|
+
? ` ${entry.data}`
|
|
251
|
+
: ` ${JSON.stringify(entry.data, null, 0).slice(0, 300)}`;
|
|
252
|
+
esLines.push(dataStr);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
esLines.push('');
|
|
256
|
+
esLines.push('利用上述信号作为分析切入点,用 read_project_file 验证并深入探索。');
|
|
257
|
+
parts.push(esLines.join('\n'));
|
|
258
|
+
}
|
|
259
|
+
// §M1: 全景上下文 (Panorama Phase 1.8) — 模块角色/层级/耦合/空白区
|
|
260
|
+
if (panorama) {
|
|
261
|
+
const pLines = ['## 🏗️ 项目全景 (Panorama)'];
|
|
262
|
+
if (panorama.layerContext) {
|
|
263
|
+
pLines.push(`架构层级: ${panorama.layerContext}`);
|
|
264
|
+
}
|
|
265
|
+
if (panorama.moduleRole) {
|
|
266
|
+
pLines.push(`当前模块角色: ${panorama.moduleRole}${panorama.moduleLayer !== null ? ` (L${panorama.moduleLayer})` : ''}`);
|
|
267
|
+
}
|
|
268
|
+
if (panorama.moduleCoupling) {
|
|
269
|
+
pLines.push(`耦合度: fanIn=${panorama.moduleCoupling.fanIn}, fanOut=${panorama.moduleCoupling.fanOut}`);
|
|
270
|
+
}
|
|
271
|
+
if (panorama.knownGaps.length > 0) {
|
|
272
|
+
pLines.push(`已知空白区: ${panorama.knownGaps.join(', ')}`);
|
|
273
|
+
pLines.push('分析时请特别关注上述空白区,它们是最可能产出新知识的方向。');
|
|
274
|
+
}
|
|
275
|
+
parts.push(pLines.join('\n'));
|
|
276
|
+
}
|
|
277
|
+
// §EVO: Evolution 结果 — 避免重复覆盖已被 Evolution Agent 处理的模式
|
|
278
|
+
if (evolutionResult && evolutionResult.totalRecipes && evolutionResult.totalRecipes > 0) {
|
|
279
|
+
const evoLines = [
|
|
280
|
+
'## 🔄 Evolution 结果',
|
|
281
|
+
`Evolution Agent 已审查本维度 ${evolutionResult.totalRecipes} 个现有 Recipe:`,
|
|
282
|
+
`- 进化: ${evolutionResult.evolved ?? 0} 个(已提交新版本替代旧 Recipe)`,
|
|
283
|
+
`- 废弃: ${evolutionResult.deprecated ?? 0} 个(已确认过时)`,
|
|
284
|
+
`- 跳过: ${evolutionResult.skipped ?? 0} 个(仍然有效或信息不足)`,
|
|
285
|
+
'',
|
|
286
|
+
'**你的分析应关注发现新知识点**,不要重复覆盖已处理的模式。',
|
|
287
|
+
];
|
|
288
|
+
parts.push(evoLines.join('\n'));
|
|
289
|
+
}
|
|
290
|
+
// §10a: Rescan 有效知识上下文 — 避免重复分析已覆盖的模式
|
|
291
|
+
if (rescanContext && rescanContext.existingRecipes.length > 0) {
|
|
292
|
+
const lines = [
|
|
293
|
+
'## ⚠️ 增量扫描模式 — 已有知识 (勿重复)',
|
|
294
|
+
`本维度已有 ${rescanContext.existing} 个有效 Recipe,需补齐 ${rescanContext.gap} 个。`,
|
|
295
|
+
'已有 Recipe 标题:',
|
|
296
|
+
];
|
|
297
|
+
for (const r of rescanContext.existingRecipes.slice(0, 10)) {
|
|
298
|
+
const triggerTag = r.trigger ? ` (trigger: ${r.trigger})` : '';
|
|
299
|
+
lines.push(`- "${r.title}"${triggerTag}`);
|
|
300
|
+
}
|
|
301
|
+
if (rescanContext.existingRecipes.length > 10) {
|
|
302
|
+
lines.push(`- ... 共 ${rescanContext.existingRecipes.length} 个`);
|
|
303
|
+
}
|
|
304
|
+
lines.push('');
|
|
305
|
+
lines.push('**你的任务**: 专注发现上述 Recipe **尚未覆盖**的新模式。不要重复分析相同的代码特征。');
|
|
306
|
+
parts.push(lines.join('\n'));
|
|
307
|
+
}
|
|
308
|
+
// §10b: Rescan 衰退知识 — 可以替换
|
|
309
|
+
if (rescanContext?.decayingRecipes && rescanContext.decayingRecipes.length > 0) {
|
|
310
|
+
const dLines = [
|
|
311
|
+
'## 🔄 衰退中的知识 (可替换)',
|
|
312
|
+
'以下 Recipe 正在衰退,其描述的模式可能已过时或迁移:',
|
|
313
|
+
];
|
|
314
|
+
for (const r of rescanContext.decayingRecipes.slice(0, 5)) {
|
|
315
|
+
dLines.push(`- "${r.title}" — 衰退原因: ${r.decayReason || '未知'}`);
|
|
316
|
+
}
|
|
317
|
+
dLines.push('如果你在分析中发现了这些模式的**更新版本**(例如类改名、迁移到新模块),');
|
|
318
|
+
dLines.push('请记录下来,后续 Producer 可以用 supersedes 参数提交替代版本。');
|
|
319
|
+
parts.push(dLines.join('\n'));
|
|
320
|
+
}
|
|
221
321
|
return parts.join('\n\n');
|
|
222
322
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* insight-evolver.ts — Evolution Agent 领域函数
|
|
3
|
+
*
|
|
4
|
+
* Evolution Agent 是管线中的专职进化角色:
|
|
5
|
+
* - 接收当前维度的**全部**现有 Recipe(不仅是衰退的)
|
|
6
|
+
* - 使用工具读取真实代码,验证每个 Recipe 的真实性
|
|
7
|
+
* - 通过**附加提案**(Proposal)驱动状态变更,不创建新 Recipe
|
|
8
|
+
* - 三种决策: propose_evolution / confirm_deprecation / skip_evolution
|
|
9
|
+
*
|
|
10
|
+
* 被 PipelineStrategy 的 evolution preset 引用。
|
|
11
|
+
* 按维度隔离:每个维度的 Evolve Stage 只处理属于该维度的 Recipe。
|
|
12
|
+
*
|
|
13
|
+
* @module insight-evolver
|
|
14
|
+
*/
|
|
15
|
+
/** 静态审计 hint(可选)— 来自 RecipeRelevanceAuditor */
|
|
16
|
+
export interface AuditHint {
|
|
17
|
+
relevanceScore: number;
|
|
18
|
+
verdict: string;
|
|
19
|
+
evidence: {
|
|
20
|
+
triggerStillMatches: boolean;
|
|
21
|
+
symbolsAlive: number;
|
|
22
|
+
depsIntact: boolean;
|
|
23
|
+
codeFilesExist: number;
|
|
24
|
+
};
|
|
25
|
+
decayReasons: string[];
|
|
26
|
+
}
|
|
27
|
+
/** 现有 Recipe(含可选的 audit hint) */
|
|
28
|
+
export interface ExistingRecipeForEvolution {
|
|
29
|
+
id: string;
|
|
30
|
+
title: string;
|
|
31
|
+
trigger: string;
|
|
32
|
+
content?: {
|
|
33
|
+
markdown?: string;
|
|
34
|
+
rationale?: string;
|
|
35
|
+
coreCode?: string;
|
|
36
|
+
};
|
|
37
|
+
sourceRefs?: string[];
|
|
38
|
+
/** 静态审计 hint — 仅供参考,Agent 应通过读代码自行验证 */
|
|
39
|
+
auditHint?: AuditHint | null;
|
|
40
|
+
}
|
|
41
|
+
/** Evolution Agent 上下文 */
|
|
42
|
+
export interface EvolutionContext {
|
|
43
|
+
/** 当前维度的全部现有 Recipe(healthy + decaying),按维度过滤后注入 */
|
|
44
|
+
existingRecipes: ExistingRecipeForEvolution[];
|
|
45
|
+
dimensionId: string;
|
|
46
|
+
dimensionLabel: string;
|
|
47
|
+
projectOverview: {
|
|
48
|
+
primaryLang: string;
|
|
49
|
+
fileCount: number;
|
|
50
|
+
modules: string[];
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export declare const EVOLVER_SYSTEM_PROMPT = "\u4F60\u662F AutoSnippet \u7684 **Evolution Agent**\uFF0C\u4E13\u804C\u9A8C\u8BC1\u9879\u76EE\u4E2D\u73B0\u6709\u77E5\u8BC6\u6761\u76EE\uFF08Recipe\uFF09\u7684\u771F\u5B9E\u6027\u4E0E\u65F6\u6548\u6027\u3002\n\n## \u6838\u5FC3\u804C\u8D23\n\n\u4F60\u901A\u8FC7\u9605\u8BFB\u9879\u76EE\u771F\u5B9E\u4EE3\u7801\u6765\u9A8C\u8BC1\u6BCF\u6761 Recipe \u662F\u5426\u4ECD\u7136\u53CD\u6620\u5F53\u524D\u9879\u76EE\u5B9E\u8DF5\u3002\n\u4F60\u7684\u5DE5\u4F5C\u7ED3\u679C\u4EE5**\u63D0\u6848\uFF08Proposal\uFF09**\u65B9\u5F0F\u9644\u52A0\u5230\u73B0\u6709 Recipe \u4E0A\uFF0C\u63A8\u52A8\u77E5\u8BC6\u5E93\u7684\u6E10\u8FDB\u5F0F\u6F14\u5316\u3002\n\u4F60**\u4E0D\u521B\u5EFA\u65B0 Recipe**\u2014\u2014\u90A3\u662F\u540E\u7EED Produce \u9636\u6BB5\u7684\u804C\u8D23\u3002\n\n## \u9A8C\u8BC1\u6D41\u7A0B\n\n\u5BF9\u6BCF\u4E2A Recipe \u6309\u4EE5\u4E0B\u6B65\u9AA4\u9A8C\u8BC1:\n1. \u9605\u8BFB Recipe \u7684\u6838\u5FC3\u4EE3\u7801\u7247\u6BB5\u548C\u6E90\u6587\u4EF6\u5F15\u7528\uFF0C\u7406\u89E3\u5176\u63CF\u8FF0\u7684\u6A21\u5F0F\n2. \u4F7F\u7528 `read_project_file` \u8BFB\u53D6\u6E90\u6587\u4EF6\uFF0C\u9A8C\u8BC1\u4EE3\u7801\u662F\u5426\u5B58\u5728\u4E14\u4E0E Recipe \u63CF\u8FF0\u5339\u914D\n3. \u5982\u679C\u6E90\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u4EE3\u7801\u4E0D\u5339\u914D\uFF0C\u4F7F\u7528 `search_project_code` \u641C\u7D22\u8BE5\u6A21\u5F0F\u662F\u5426\u5DF2\u8FC1\u79FB\u5230\u5176\u4ED6\u4F4D\u7F6E\n4. \u57FA\u4E8E\u771F\u5B9E\u4EE3\u7801\u7684\u9A8C\u8BC1\u7ED3\u679C\u505A\u51FA\u51B3\u7B56\n\n## \u51B3\u7B56\u89C4\u5219\n\n\u6309\u4EE5\u4E0B\u51B3\u7B56\u6811\u5224\u65AD\uFF08\u4F18\u5148\u7EA7\u4ECE\u4E0A\u5230\u4E0B\uFF09:\n\n| \u9A8C\u8BC1\u7ED3\u679C | \u51B3\u7B56 | \u5DE5\u5177 |\n|---------|------|------|\n| \u6E90\u6587\u4EF6\u5B58\u5728 + \u4EE3\u7801\u5339\u914D Recipe \u63CF\u8FF0 | **\u8DF3\u8FC7**: \u4ECD\u7136\u6709\u6548 | `skip_evolution` |\n| \u6E90\u6587\u4EF6\u5B58\u5728 + \u4EE3\u7801\u5DF2\u53D8\u5316\uFF08\u63A5\u53E3\u6539\u53D8/\u91CD\u6784\uFF09 | **\u8FDB\u5316\u63D0\u6848**: \u9644\u52A0\u53D8\u66F4\u8BC1\u636E | `propose_evolution` |\n| \u6E90\u6587\u4EF6\u4E0D\u5B58\u5728 + \u6A21\u5F0F\u5DF2\u8FC1\u79FB\u5230\u65B0\u4F4D\u7F6E | **\u8FDB\u5316\u63D0\u6848**: \u9644\u52A0\u8FC1\u79FB\u8BC1\u636E | `propose_evolution` |\n| \u6E90\u6587\u4EF6\u4E0D\u5B58\u5728 + \u5B8C\u5168\u65E0\u66FF\u4EE3 | **\u786E\u8BA4\u5E9F\u5F03**: \u77E5\u8BC6\u5DF2\u5931\u6548 | `confirm_deprecation` |\n| \u4FE1\u606F\u4E0D\u8DB3\u4EE5\u505A\u51FA\u5224\u65AD | **\u8DF3\u8FC7**: \u4EA4\u7ED9\u65F6\u9650\u673A\u5236 | `skip_evolution` |\n\n## \u5DE5\u5177\u8BF4\u660E\n\n- `propose_evolution` \u2014 \u4E3A Recipe \u9644\u52A0\u8FDB\u5316\u63D0\u6848\uFF0C\u5305\u542B\u4EE3\u7801\u9A8C\u8BC1\u8BC1\u636E\u548C\u5EFA\u8BAE\u53D8\u66F4\u3002\u63D0\u6848\u8FDB\u5165\u89C2\u5BDF\u7A97\u53E3\uFF08enhance: 48h, correction: 24h\uFF09\uFF0C\u4E0D\u76F4\u63A5\u4FEE\u6539 Recipe\n- `confirm_deprecation` \u2014 \u786E\u8BA4 Recipe \u5DF2\u8FC7\u65F6\uFF0C\u7ACB\u5373\u6807\u8BB0\u4E3A deprecated\uFF08\u8DF3\u8FC7\u89C2\u5BDF\u7A97\u53E3\uFF09\n- `skip_evolution` \u2014 \u663E\u5F0F\u8DF3\u8FC7\uFF0Creason \u4E2D\u8BF4\u660E\u662F\"\u9A8C\u8BC1\u6709\u6548\"\u8FD8\u662F\"\u4FE1\u606F\u4E0D\u8DB3\"\n\n## \u91CD\u8981\u7EA6\u675F\n\n- \u6BCF\u4E2A Recipe \u5FC5\u987B\u6709\u4E00\u4E2A\u660E\u786E\u51B3\u7B56\uFF0C\u4E0D\u8981\u9057\u6F0F\u4EFB\u4F55\u4E00\u4E2A\n- `propose_evolution` \u7684 evidence \u5B57\u6BB5\u5FC5\u987B\u5305\u542B\u4F60\u8BFB\u5230\u7684\u771F\u5B9E\u4EE3\u7801\uFF0C\u4E0D\u8981\u7F16\u9020\n- `propose_evolution` \u7684 type \u533A\u5206: enhance\uFF08\u6A21\u5F0F\u8FC1\u79FB/\u529F\u80FD\u6269\u5C55\uFF09vs correction\uFF08\u63CF\u8FF0\u9519\u8BEF/\u63A5\u53E3\u53D8\u66F4\uFF09\n- \u90E8\u5206 Recipe \u9644\u5E26\u7CFB\u7EDF\u9884\u68C0\u63D0\u793A\uFF08auditHint\uFF09\uFF0C\u4EC5\u4F9B\u53C2\u8003\u2014\u2014\u4F60\u5FC5\u987B\u4EE5\u5B9E\u9645\u8BFB\u5230\u7684\u4EE3\u7801\u4E3A\u51C6\n- \u5373\u4F7F\u9884\u68C0\u63D0\u793A\u8BF4\"healthy\"\uFF0C\u4F60\u8BFB\u4EE3\u7801\u540E\u53D1\u73B0\u4E0D\u5339\u914D\u4E5F\u8981\u63D0\u4EA4\u63D0\u6848";
|
|
54
|
+
export declare const EVOLVER_TOOLS: string[];
|
|
55
|
+
export declare const EVOLVER_BUDGET: {
|
|
56
|
+
maxIterations: number;
|
|
57
|
+
searchBudget: number;
|
|
58
|
+
searchBudgetGrace: number;
|
|
59
|
+
maxSubmits: number;
|
|
60
|
+
softSubmitLimit: number;
|
|
61
|
+
idleRoundsToExit: number;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* 构建 Evolution Agent 的用户 Prompt
|
|
65
|
+
*
|
|
66
|
+
* 按维度打包全部现有 Recipe 清单 + 可选 audit hint + 项目概览,
|
|
67
|
+
* 让 Agent 通过提案机制对每个 Recipe 做出进化/废弃/跳过决策。
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildEvolverPrompt(_phaseInput: unknown, _phaseResults: unknown, strategyContext: EvolutionContext): string;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* insight-evolver.ts — Evolution Agent 领域函数
|
|
3
|
+
*
|
|
4
|
+
* Evolution Agent 是管线中的专职进化角色:
|
|
5
|
+
* - 接收当前维度的**全部**现有 Recipe(不仅是衰退的)
|
|
6
|
+
* - 使用工具读取真实代码,验证每个 Recipe 的真实性
|
|
7
|
+
* - 通过**附加提案**(Proposal)驱动状态变更,不创建新 Recipe
|
|
8
|
+
* - 三种决策: propose_evolution / confirm_deprecation / skip_evolution
|
|
9
|
+
*
|
|
10
|
+
* 被 PipelineStrategy 的 evolution preset 引用。
|
|
11
|
+
* 按维度隔离:每个维度的 Evolve Stage 只处理属于该维度的 Recipe。
|
|
12
|
+
*
|
|
13
|
+
* @module insight-evolver
|
|
14
|
+
*/
|
|
15
|
+
// ──────────────────────────────────────────────────────────────────
|
|
16
|
+
// System Prompt
|
|
17
|
+
// ──────────────────────────────────────────────────────────────────
|
|
18
|
+
export const EVOLVER_SYSTEM_PROMPT = `你是 AutoSnippet 的 **Evolution Agent**,专职验证项目中现有知识条目(Recipe)的真实性与时效性。
|
|
19
|
+
|
|
20
|
+
## 核心职责
|
|
21
|
+
|
|
22
|
+
你通过阅读项目真实代码来验证每条 Recipe 是否仍然反映当前项目实践。
|
|
23
|
+
你的工作结果以**提案(Proposal)**方式附加到现有 Recipe 上,推动知识库的渐进式演化。
|
|
24
|
+
你**不创建新 Recipe**——那是后续 Produce 阶段的职责。
|
|
25
|
+
|
|
26
|
+
## 验证流程
|
|
27
|
+
|
|
28
|
+
对每个 Recipe 按以下步骤验证:
|
|
29
|
+
1. 阅读 Recipe 的核心代码片段和源文件引用,理解其描述的模式
|
|
30
|
+
2. 使用 \`read_project_file\` 读取源文件,验证代码是否存在且与 Recipe 描述匹配
|
|
31
|
+
3. 如果源文件不存在或代码不匹配,使用 \`search_project_code\` 搜索该模式是否已迁移到其他位置
|
|
32
|
+
4. 基于真实代码的验证结果做出决策
|
|
33
|
+
|
|
34
|
+
## 决策规则
|
|
35
|
+
|
|
36
|
+
按以下决策树判断(优先级从上到下):
|
|
37
|
+
|
|
38
|
+
| 验证结果 | 决策 | 工具 |
|
|
39
|
+
|---------|------|------|
|
|
40
|
+
| 源文件存在 + 代码匹配 Recipe 描述 | **跳过**: 仍然有效 | \`skip_evolution\` |
|
|
41
|
+
| 源文件存在 + 代码已变化(接口改变/重构) | **进化提案**: 附加变更证据 | \`propose_evolution\` |
|
|
42
|
+
| 源文件不存在 + 模式已迁移到新位置 | **进化提案**: 附加迁移证据 | \`propose_evolution\` |
|
|
43
|
+
| 源文件不存在 + 完全无替代 | **确认废弃**: 知识已失效 | \`confirm_deprecation\` |
|
|
44
|
+
| 信息不足以做出判断 | **跳过**: 交给时限机制 | \`skip_evolution\` |
|
|
45
|
+
|
|
46
|
+
## 工具说明
|
|
47
|
+
|
|
48
|
+
- \`propose_evolution\` — 为 Recipe 附加进化提案,包含代码验证证据和建议变更。提案进入观察窗口(enhance: 48h, correction: 24h),不直接修改 Recipe
|
|
49
|
+
- \`confirm_deprecation\` — 确认 Recipe 已过时,立即标记为 deprecated(跳过观察窗口)
|
|
50
|
+
- \`skip_evolution\` — 显式跳过,reason 中说明是"验证有效"还是"信息不足"
|
|
51
|
+
|
|
52
|
+
## 重要约束
|
|
53
|
+
|
|
54
|
+
- 每个 Recipe 必须有一个明确决策,不要遗漏任何一个
|
|
55
|
+
- \`propose_evolution\` 的 evidence 字段必须包含你读到的真实代码,不要编造
|
|
56
|
+
- \`propose_evolution\` 的 type 区分: enhance(模式迁移/功能扩展)vs correction(描述错误/接口变更)
|
|
57
|
+
- 部分 Recipe 附带系统预检提示(auditHint),仅供参考——你必须以实际读到的代码为准
|
|
58
|
+
- 即使预检提示说"healthy",你读代码后发现不匹配也要提交提案`;
|
|
59
|
+
// ──────────────────────────────────────────────────────────────────
|
|
60
|
+
// 工具白名单
|
|
61
|
+
// ──────────────────────────────────────────────────────────────────
|
|
62
|
+
export const EVOLVER_TOOLS = [
|
|
63
|
+
'read_project_file',
|
|
64
|
+
'search_project_code',
|
|
65
|
+
'propose_evolution',
|
|
66
|
+
'confirm_deprecation',
|
|
67
|
+
'skip_evolution',
|
|
68
|
+
];
|
|
69
|
+
// ──────────────────────────────────────────────────────────────────
|
|
70
|
+
// 预算
|
|
71
|
+
// ──────────────────────────────────────────────────────────────────
|
|
72
|
+
export const EVOLVER_BUDGET = {
|
|
73
|
+
maxIterations: 20,
|
|
74
|
+
searchBudget: 10,
|
|
75
|
+
searchBudgetGrace: 4,
|
|
76
|
+
maxSubmits: 8,
|
|
77
|
+
softSubmitLimit: 8,
|
|
78
|
+
idleRoundsToExit: 2,
|
|
79
|
+
};
|
|
80
|
+
// ──────────────────────────────────────────────────────────────────
|
|
81
|
+
// Prompt 构建
|
|
82
|
+
// ──────────────────────────────────────────────────────────────────
|
|
83
|
+
/**
|
|
84
|
+
* 构建 Evolution Agent 的用户 Prompt
|
|
85
|
+
*
|
|
86
|
+
* 按维度打包全部现有 Recipe 清单 + 可选 audit hint + 项目概览,
|
|
87
|
+
* 让 Agent 通过提案机制对每个 Recipe 做出进化/废弃/跳过决策。
|
|
88
|
+
*/
|
|
89
|
+
export function buildEvolverPrompt(_phaseInput, _phaseResults, strategyContext) {
|
|
90
|
+
const { existingRecipes, dimensionId, dimensionLabel, projectOverview } = strategyContext;
|
|
91
|
+
const parts = [];
|
|
92
|
+
// §1 任务概述
|
|
93
|
+
parts.push(`# 验证任务: ${dimensionLabel} [${dimensionId}]`);
|
|
94
|
+
parts.push(`你需要验证 **${existingRecipes.length}** 个现有 Recipe 的真实性。`);
|
|
95
|
+
parts.push(`项目概况: ${projectOverview.primaryLang} 语言,${projectOverview.fileCount} 个文件。`);
|
|
96
|
+
if (projectOverview.modules.length > 0) {
|
|
97
|
+
parts.push(`主要模块: ${projectOverview.modules.slice(0, 10).join(', ')}`);
|
|
98
|
+
}
|
|
99
|
+
// §2 现有 Recipe 清单
|
|
100
|
+
parts.push('# 现有 Recipe 清单');
|
|
101
|
+
parts.push('以下是需要你验证的全部 Recipe。对每一个,你需要读取源文件、验证代码、然后做出决策。');
|
|
102
|
+
for (let i = 0; i < existingRecipes.length; i++) {
|
|
103
|
+
const recipe = existingRecipes[i];
|
|
104
|
+
const lines = [];
|
|
105
|
+
lines.push(`## [${i + 1}/${existingRecipes.length}] ${recipe.title}`);
|
|
106
|
+
lines.push(`- **ID**: \`${recipe.id}\``);
|
|
107
|
+
lines.push(`- **Trigger**: \`${recipe.trigger}\``);
|
|
108
|
+
// 源文件引用 — 验证的起点
|
|
109
|
+
if (recipe.sourceRefs && recipe.sourceRefs.length > 0) {
|
|
110
|
+
lines.push(`- **源文件引用** (请用 \`read_project_file\` 读取验证):`);
|
|
111
|
+
for (const ref of recipe.sourceRefs.slice(0, 5)) {
|
|
112
|
+
lines.push(` - \`${ref}\``);
|
|
113
|
+
}
|
|
114
|
+
if (recipe.sourceRefs.length > 5) {
|
|
115
|
+
lines.push(` - ... 及其他 ${recipe.sourceRefs.length - 5} 个文件`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
lines.push('- **源文件引用**: 无(需要用 `search_project_code` 搜索相关代码)');
|
|
120
|
+
}
|
|
121
|
+
// Recipe 声称的核心代码(缩略)
|
|
122
|
+
if (recipe.content?.coreCode) {
|
|
123
|
+
const truncated = recipe.content.coreCode.length > 400
|
|
124
|
+
? `${recipe.content.coreCode.slice(0, 400)}...`
|
|
125
|
+
: recipe.content.coreCode;
|
|
126
|
+
lines.push(`- **Recipe 声称的核心代码** (需验证是否与实际一致):`);
|
|
127
|
+
lines.push(`\`\`\`\n${truncated}\n\`\`\``);
|
|
128
|
+
}
|
|
129
|
+
// Recipe 的设计原理
|
|
130
|
+
if (recipe.content?.rationale) {
|
|
131
|
+
const rationale = recipe.content.rationale.length > 200
|
|
132
|
+
? `${recipe.content.rationale.slice(0, 200)}...`
|
|
133
|
+
: recipe.content.rationale;
|
|
134
|
+
lines.push(`- **设计原理**: ${rationale}`);
|
|
135
|
+
}
|
|
136
|
+
// 静态审计 hint(可选)
|
|
137
|
+
if (recipe.auditHint) {
|
|
138
|
+
lines.push('- **系统预检提示** ⚠️ 仅供参考,以你读到的代码为准:');
|
|
139
|
+
lines.push(` - 评分: ${recipe.auditHint.relevanceScore}/100 → ${recipe.auditHint.verdict}`);
|
|
140
|
+
const ev = recipe.auditHint.evidence;
|
|
141
|
+
const checks = [
|
|
142
|
+
`Trigger: ${ev.triggerStillMatches ? '✅' : '❌'}`,
|
|
143
|
+
`符号: ${(ev.symbolsAlive * 100).toFixed(0)}%`,
|
|
144
|
+
`依赖: ${ev.depsIntact ? '✅' : '❌'}`,
|
|
145
|
+
`代码文件: ${(ev.codeFilesExist * 100).toFixed(0)}%`,
|
|
146
|
+
];
|
|
147
|
+
lines.push(` - ${checks.join(' | ')}`);
|
|
148
|
+
if (recipe.auditHint.decayReasons.length > 0) {
|
|
149
|
+
lines.push(` - 预检原因: ${recipe.auditHint.decayReasons.join('; ')}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
parts.push(lines.join('\n'));
|
|
153
|
+
}
|
|
154
|
+
// §3 验证工作流
|
|
155
|
+
parts.push('# 验证工作流');
|
|
156
|
+
parts.push('对每个 Recipe 按以下步骤执行:');
|
|
157
|
+
parts.push('');
|
|
158
|
+
parts.push('**步骤 1 — 读取源文件**');
|
|
159
|
+
parts.push('- 使用 `read_project_file` 读取 sourceRefs 中列出的文件');
|
|
160
|
+
parts.push('- 如果没有 sourceRefs,跳到步骤 2');
|
|
161
|
+
parts.push('');
|
|
162
|
+
parts.push('**步骤 2 — 搜索验证**(仅在源文件缺失或代码不匹配时)');
|
|
163
|
+
parts.push('- 使用 `search_project_code` 搜索 Recipe 中的类名、函数名、关键模式');
|
|
164
|
+
parts.push('- 确认该模式是否迁移到了新位置或已被完全移除');
|
|
165
|
+
parts.push('');
|
|
166
|
+
parts.push('**步骤 3 — 做出决策**');
|
|
167
|
+
parts.push('- 基于步骤 1-2 的验证结果,调用对应的决策工具');
|
|
168
|
+
// §4 决策指令
|
|
169
|
+
parts.push('# 决策指令');
|
|
170
|
+
parts.push('对上述每个 Recipe 做出以下三种决策之一:');
|
|
171
|
+
parts.push('');
|
|
172
|
+
parts.push('### 1. 🔄 附加进化提案 — 代码已变但知识仍有价值');
|
|
173
|
+
parts.push('调用 `propose_evolution`:');
|
|
174
|
+
parts.push('```json');
|
|
175
|
+
parts.push('{');
|
|
176
|
+
parts.push(' "recipeId": "recipe-xxx",');
|
|
177
|
+
parts.push(' "type": "enhance", // enhance=模式迁移/功能扩展, correction=描述错误/接口变更');
|
|
178
|
+
parts.push(' "description": "说明发生了什么变化",');
|
|
179
|
+
parts.push(' "evidence": {');
|
|
180
|
+
parts.push(' "sourceStatus": "modified", // exists|moved|modified|deleted');
|
|
181
|
+
parts.push(' "currentCode": "你读到的实际代码片段",');
|
|
182
|
+
parts.push(' "newLocation": "新路径(仅 moved 时)",');
|
|
183
|
+
parts.push(' "suggestedChanges": "{结构化 JSON — 见下方格式}"');
|
|
184
|
+
parts.push(' },');
|
|
185
|
+
parts.push(' "confidence": 0.85');
|
|
186
|
+
parts.push('}');
|
|
187
|
+
parts.push('```');
|
|
188
|
+
parts.push('');
|
|
189
|
+
parts.push('#### suggestedChanges 格式(重要!)');
|
|
190
|
+
parts.push('suggestedChanges 必须是一个 JSON 字符串,格式如下:');
|
|
191
|
+
parts.push('```json');
|
|
192
|
+
parts.push('{');
|
|
193
|
+
parts.push(' "patchVersion": 1,');
|
|
194
|
+
parts.push(' "changes": [');
|
|
195
|
+
parts.push(' {');
|
|
196
|
+
parts.push(' "field": "coreCode",');
|
|
197
|
+
parts.push(' "action": "replace",');
|
|
198
|
+
parts.push(' "newValue": "更新后的代码片段"');
|
|
199
|
+
parts.push(' },');
|
|
200
|
+
parts.push(' {');
|
|
201
|
+
parts.push(' "field": "content.markdown",');
|
|
202
|
+
parts.push(' "action": "replace-section",');
|
|
203
|
+
parts.push(' "section": "### 使用指南",');
|
|
204
|
+
parts.push(' "newContent": "### 使用指南\\n更新后的内容"');
|
|
205
|
+
parts.push(' }');
|
|
206
|
+
parts.push(' ],');
|
|
207
|
+
parts.push(' "reasoning": "源代码变更原因说明"');
|
|
208
|
+
parts.push('}');
|
|
209
|
+
parts.push('```');
|
|
210
|
+
parts.push('');
|
|
211
|
+
parts.push('可修改的字段: `coreCode`, `doClause`, `dontClause`, `whenClause`, `content.markdown`, `content.rationale`, `sourceRefs`, `headers`');
|
|
212
|
+
parts.push('操作类型: `replace`=全量替换, `replace-section`=替换 Markdown section, `append`=追加');
|
|
213
|
+
parts.push('');
|
|
214
|
+
parts.push('### 2. ⛔ 确认废弃 — 知识确实过时,无法挽救');
|
|
215
|
+
parts.push('调用 `confirm_deprecation`:');
|
|
216
|
+
parts.push('```json');
|
|
217
|
+
parts.push('{ "recipeId": "recipe-xxx", "reason": "具体废弃原因" }');
|
|
218
|
+
parts.push('```');
|
|
219
|
+
parts.push('');
|
|
220
|
+
parts.push('### 3. ⏭️ 跳过 — 仍然有效 或 信息不足');
|
|
221
|
+
parts.push('调用 `skip_evolution`:');
|
|
222
|
+
parts.push('```json');
|
|
223
|
+
parts.push('{ "recipeId": "recipe-xxx", "reason": "验证有效: 代码与描述完全匹配" }');
|
|
224
|
+
parts.push('```');
|
|
225
|
+
parts.push('或:');
|
|
226
|
+
parts.push('```json');
|
|
227
|
+
parts.push('{ "recipeId": "recipe-xxx", "reason": "信息不足: 无法确认源文件位置" }');
|
|
228
|
+
parts.push('```');
|
|
229
|
+
return parts.join('\n\n');
|
|
230
|
+
}
|
|
@@ -190,4 +190,46 @@ export declare function insightGateEvaluator(source: unknown, phaseResults: Reco
|
|
|
190
190
|
};
|
|
191
191
|
};
|
|
192
192
|
};
|
|
193
|
+
/** Tool call record for evolution gate */
|
|
194
|
+
interface EvolutionToolCallRecord {
|
|
195
|
+
tool?: string;
|
|
196
|
+
name?: string;
|
|
197
|
+
args?: Record<string, unknown>;
|
|
198
|
+
result?: unknown;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Evolution Gate 评估器 — 面向 PipelineStrategy gate.evaluator
|
|
202
|
+
*
|
|
203
|
+
* 检查 Evolution Agent 是否对所有现有 Recipe 做出了决策:
|
|
204
|
+
* - evolved (submit_knowledge with supersedes)
|
|
205
|
+
* - deprecated (confirm_deprecation)
|
|
206
|
+
* - skipped (skip_evolution)
|
|
207
|
+
*
|
|
208
|
+
* 如果还有未处理的 Recipe,返回 retry 要求补充决策。
|
|
209
|
+
*
|
|
210
|
+
* 兼容旧字段: 优先读 existingRecipes,回退 decayedRecipes。
|
|
211
|
+
*/
|
|
212
|
+
export declare function evolutionGateEvaluator(source: {
|
|
213
|
+
toolCalls?: EvolutionToolCallRecord[];
|
|
214
|
+
} | null | undefined, _phaseResults: unknown, strategyContext?: {
|
|
215
|
+
existingRecipes?: Array<{
|
|
216
|
+
id: string;
|
|
217
|
+
}>;
|
|
218
|
+
decayedRecipes?: Array<{
|
|
219
|
+
id: string;
|
|
220
|
+
}>;
|
|
221
|
+
}): {
|
|
222
|
+
action: string;
|
|
223
|
+
reason: string;
|
|
224
|
+
artifact?: undefined;
|
|
225
|
+
} | {
|
|
226
|
+
action: string;
|
|
227
|
+
artifact: {
|
|
228
|
+
evolved: number;
|
|
229
|
+
deprecated: number;
|
|
230
|
+
skipped: number;
|
|
231
|
+
totalRecipes: number;
|
|
232
|
+
};
|
|
233
|
+
reason?: undefined;
|
|
234
|
+
};
|
|
193
235
|
export {};
|
|
@@ -382,6 +382,47 @@ export function insightGateEvaluator(source, phaseResults, strategyContext = {})
|
|
|
382
382
|
artifact,
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Evolution Gate 评估器 — 面向 PipelineStrategy gate.evaluator
|
|
387
|
+
*
|
|
388
|
+
* 检查 Evolution Agent 是否对所有现有 Recipe 做出了决策:
|
|
389
|
+
* - evolved (submit_knowledge with supersedes)
|
|
390
|
+
* - deprecated (confirm_deprecation)
|
|
391
|
+
* - skipped (skip_evolution)
|
|
392
|
+
*
|
|
393
|
+
* 如果还有未处理的 Recipe,返回 retry 要求补充决策。
|
|
394
|
+
*
|
|
395
|
+
* 兼容旧字段: 优先读 existingRecipes,回退 decayedRecipes。
|
|
396
|
+
*/
|
|
397
|
+
export function evolutionGateEvaluator(source, _phaseResults, strategyContext = {}) {
|
|
398
|
+
const totalRecipes = (strategyContext.existingRecipes ?? strategyContext.decayedRecipes ?? [])
|
|
399
|
+
.length;
|
|
400
|
+
const toolCalls = source?.toolCalls || [];
|
|
401
|
+
// 统计各决策数
|
|
402
|
+
const evolved = toolCalls.filter((tc) => {
|
|
403
|
+
const tool = tc.tool || tc.name;
|
|
404
|
+
return tool === 'submit_knowledge' && tc.args?.supersedes;
|
|
405
|
+
}).length;
|
|
406
|
+
const deprecated = toolCalls.filter((tc) => {
|
|
407
|
+
const tool = tc.tool || tc.name;
|
|
408
|
+
return tool === 'confirm_deprecation';
|
|
409
|
+
}).length;
|
|
410
|
+
const skipped = toolCalls.filter((tc) => {
|
|
411
|
+
const tool = tc.tool || tc.name;
|
|
412
|
+
return tool === 'skip_evolution';
|
|
413
|
+
}).length;
|
|
414
|
+
const processed = evolved + deprecated + skipped;
|
|
415
|
+
if (totalRecipes > 0 && processed < totalRecipes) {
|
|
416
|
+
return {
|
|
417
|
+
action: 'retry',
|
|
418
|
+
reason: `只处理了 ${processed}/${totalRecipes} 个 Recipe,还有 ${totalRecipes - processed} 个未决策`,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
return {
|
|
422
|
+
action: 'pass',
|
|
423
|
+
artifact: { evolved, deprecated, skipped, totalRecipes },
|
|
424
|
+
};
|
|
425
|
+
}
|
|
385
426
|
// ──────────────────────────────────────────────────────────────────
|
|
386
427
|
// 类型定义 (JSDoc)
|
|
387
428
|
// ──────────────────────────────────────────────────────────────────
|
|
@@ -62,7 +62,7 @@ interface GateStrategyContext {
|
|
|
62
62
|
submitToolNames?: string[];
|
|
63
63
|
[key: string]: unknown;
|
|
64
64
|
}
|
|
65
|
-
export declare const PRODUCER_SYSTEM_PROMPT = "\u4F60\u662F\u77E5\u8BC6\u7BA1\u7406\u4E13\u5BB6\u3002\u4F60\u4F1A\u6536\u5230\u4E00\u6BB5\u4EE3\u7801\u5206\u6790\u6587\u672C\uFF0C\u9700\u8981\u5C06\u5176\u4E2D\u7684\u77E5\u8BC6\u70B9\u8F6C\u5316\u4E3A\u7ED3\u6784\u5316\u7684\u77E5\u8BC6\u5019\u9009\u3002\n\n\u6838\u5FC3\u539F\u5219: \u5206\u6790\u6587\u672C\u5DF2\u7ECF\u5305\u542B\u4E86\u6240\u6709\u53D1\u73B0\uFF0C\u4F60\u7684\u552F\u4E00\u5DE5\u4F5C\u662F\u5C06\u5B83\u4EEC\u683C\u5F0F\u5316\u4E3A submit_knowledge \u8C03\u7528\u3002\n\n\u6BCF\u4E2A\u5019\u9009\u5FC5\u987B:\n1. \u6709\u6E05\u6670\u7684\u6807\u9898 (\u63CF\u8FF0\u77E5\u8BC6\u70B9\u7684\u6838\u5FC3\uFF0C\u4F7F\u7528\u9879\u76EE\u771F\u5B9E\u7C7B\u540D)\n2. \u6709\u9879\u76EE\u7279\u5199\u98CE\u683C\u7684\u6B63\u6587 (content.markdown \u5B57\u6BB5\uFF0C\u7ED3\u5408\u4EE3\u7801\u5C55\u793A)\n3. \u6807\u6CE8\u76F8\u5173\u6587\u4EF6\u8DEF\u5F84\n4. \u9009\u62E9\u6B63\u786E\u7684 kind (rule/pattern/fact)\n5. \u63D0\u4F9B\u5B8C\u6574\u7684 Cursor \u4EA4\u4ED8\u5B57\u6BB5 (trigger, doClause, whenClause \u7B49)\n\n\u5DE5\u4F5C\u6D41\u7A0B:\n1. \u9605\u8BFB\u5206\u6790\u6587\u672C\uFF0C\u8BC6\u522B\u6BCF\u4E2A\u72EC\u7ACB\u7684\u77E5\u8BC6\u70B9/\u53D1\u73B0\n2. \u7528 read_project_file \u6279\u91CF\u83B7\u53D6\u5173\u952E\u4EE3\u7801\u7247\u6BB5:\n read_project_file({ filePaths: [\"FileA.
|
|
65
|
+
export declare const PRODUCER_SYSTEM_PROMPT = "\u4F60\u662F\u77E5\u8BC6\u7BA1\u7406\u4E13\u5BB6\u3002\u4F60\u4F1A\u6536\u5230\u4E00\u6BB5\u4EE3\u7801\u5206\u6790\u6587\u672C\uFF0C\u9700\u8981\u5C06\u5176\u4E2D\u7684\u77E5\u8BC6\u70B9\u8F6C\u5316\u4E3A\u7ED3\u6784\u5316\u7684\u77E5\u8BC6\u5019\u9009\u3002\n\n\u6838\u5FC3\u539F\u5219: \u5206\u6790\u6587\u672C\u5DF2\u7ECF\u5305\u542B\u4E86\u6240\u6709\u53D1\u73B0\uFF0C\u4F60\u7684\u552F\u4E00\u5DE5\u4F5C\u662F\u5C06\u5B83\u4EEC\u683C\u5F0F\u5316\u4E3A submit_knowledge \u8C03\u7528\u3002\n\n\u6BCF\u4E2A\u5019\u9009\u5FC5\u987B:\n1. \u6709\u6E05\u6670\u7684\u6807\u9898 (\u63CF\u8FF0\u77E5\u8BC6\u70B9\u7684\u6838\u5FC3\uFF0C\u4F7F\u7528\u9879\u76EE\u771F\u5B9E\u7C7B\u540D\uFF0C\u4E0D\u4EE5\u9879\u76EE\u540D\u5F00\u5934)\n2. \u6709\u9879\u76EE\u7279\u5199\u98CE\u683C\u7684\u6B63\u6587 (content.markdown \u5B57\u6BB5\uFF0C\u7ED3\u5408\u4EE3\u7801\u5C55\u793A)\n3. \u6807\u6CE8\u76F8\u5173\u6587\u4EF6\u7684\u5B8C\u6574\u76F8\u5BF9\u8DEF\u5F84 + \u884C\u53F7\uFF08\u4ECE\u9879\u76EE\u6839\u76EE\u5F55\u5F00\u59CB\uFF0C\u5982 Packages/AOXNetworkKit/Sources/.../NetworkClient.swift:42\uFF09\n4. \u9009\u62E9\u6B63\u786E\u7684 kind (rule/pattern/fact)\n5. \u63D0\u4F9B\u5B8C\u6574\u7684 Cursor \u4EA4\u4ED8\u5B57\u6BB5 (trigger, doClause, whenClause \u7B49)\n6. \u6807\u6CE8\u6240\u5C5E\u6A21\u5757/\u5305\u540D\uFF08\u5982\u300C\u6240\u5C5E\u6A21\u5757: AOXNetworkKit\u300D\uFF09\uFF0C\u7279\u522B\u662F\u6765\u81EA\u672C\u5730\u5B50\u5305\u7684\u77E5\u8BC6\n\n\u5DE5\u4F5C\u6D41\u7A0B:\n1. \u9605\u8BFB\u5206\u6790\u6587\u672C\uFF0C\u8BC6\u522B\u6BCF\u4E2A\u72EC\u7ACB\u7684\u77E5\u8BC6\u70B9/\u53D1\u73B0\n2. \u7528 read_project_file \u6279\u91CF\u83B7\u53D6\u5173\u952E\u4EE3\u7801\u7247\u6BB5:\n read_project_file({ filePaths: [\"Full/Path/To/FileA.swift\", \"Full/Path/To/FileB.swift\"], maxLines: 80 })\n3. \u7ACB\u523B\u8C03\u7528 submit_knowledge \u63D0\u4EA4\n4. \u91CD\u590D\u76F4\u5230\u5206\u6790\u4E2D\u7684\u6240\u6709\u77E5\u8BC6\u70B9\u90FD\u5DF2\u63D0\u4EA4\n\n\u5173\u952E\u89C4\u5219:\n- \u5206\u6790\u4E2D\u7684\u6BCF\u4E2A\u8981\u70B9/\u6BB5\u843D\u90FD\u5E94\u8F6C\u5316\u4E3A\u81F3\u5C11\u4E00\u4E2A\u5019\u9009\n- read_project_file \u652F\u6301 filePaths \u6570\u7EC4\u6279\u91CF\u8BFB\u53D6\u591A\u4E2A\u6587\u4EF6\uFF0C\u4E00\u6B21\u8C03\u7528\u5B8C\u6210\n- read_project_file \u65F6\u8BFB\u53D6\u8DB3\u591F\u591A\u7684\u884C\u6570\uFF08startLine + maxLines \u81F3\u5C11 30 \u884C\uFF09\n- reasoning.sources \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4\uFF0C\u586B\u5199\u6587\u4EF6\u7684\u5B8C\u6574\u76F8\u5BF9\u8DEF\u5F84\u5982 [\"Packages/AOXNetworkKit/Sources/AOXNetworkKit/Client/NetworkClient.swift\"]\uFF08\u7981\u6B62\u53EA\u5199\u6587\u4EF6\u540D\uFF09\n- content.markdown \u4E2D\u7684\u6765\u6E90\u6807\u6CE8\u5FC5\u987B\u4F7F\u7528\u5B8C\u6574\u76F8\u5BF9\u8DEF\u5F84+\u884C\u53F7: (\u6765\u6E90: Full/Path/FileName.ext:\u884C\u53F7)\n- \u5982\u679C\u5206\u6790\u63D0\u5230\u4E86 3 \u4E2A\u6A21\u5F0F\uFF0C\u5C31\u5E94\u8BE5\u63D0\u4EA4 3 \u4E2A\u5019\u9009\uFF0C\u4E0D\u8981\u5408\u5E76\n- \u7981\u6B62: \u4E0D\u8981\u641C\u7D22\u65B0\u6587\u4EF6\u3001\u4E0D\u8981\u505A\u989D\u5916\u5206\u6790\uFF0C\u4E13\u6CE8\u4E8E\u683C\u5F0F\u5316\u548C\u63D0\u4EA4\n- \u3010\u8DE8\u7EF4\u5EA6\u53BB\u91CD\u3011\u6BCF\u6761\u5019\u9009\u5FC5\u987B\u805A\u7126\u5F53\u524D\u7EF4\u5EA6\u72EC\u6709\u7684\u89C6\u89D2\uFF0C\u4E0D\u5F97\u5C06\u540C\u4E00\u77E5\u8BC6\u70B9\u6362\u4E2A\u8BF4\u6CD5\u91CD\u590D\u63D0\u4EA4\u3002\u76F8\u540C\u7684\u7C7B/\u6A21\u5F0F\u53EA\u5728\u6700\u76F8\u5173\u7684\u7EF4\u5EA6\u51FA\u73B0\u4E00\u6B21\uFF0C\u5B81\u53EF\u5C11\u63D0\u4EA4\u4E5F\u4E0D\u8981\u5145\u6570\n\n\u5BB9\u9519\u89C4\u5219:\n- \u5982\u679C read_project_file \u8FD4\u56DE\"\u6587\u4EF6\u4E0D\u5B58\u5728\"\u6216\u9519\u8BEF\uFF0C\u4E0D\u8981\u91CD\u8BD5\u540C\u4E00\u6587\u4EF6\u7684\u5176\u4ED6\u8DEF\u5F84\u53D8\u4F53\n- \u6587\u4EF6\u8BFB\u53D6\u5931\u8D25\u65F6\uFF0C\u76F4\u63A5\u4F7F\u7528\u5206\u6790\u6587\u672C\u4E2D\u5DF2\u6709\u7684\u4EE3\u7801\u548C\u63CF\u8FF0\u6765\u63D0\u4EA4\u5019\u9009\n- \u6C38\u8FDC\u4E0D\u8981\u56E0\u4E3A\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25\u800C\u8DF3\u8FC7\u77E5\u8BC6\u70B9 \u2014 \u5206\u6790\u6587\u672C\u5DF2\u7ECF\u5305\u542B\u8DB3\u591F\u4FE1\u606F\n- \u5148\u63D0\u4EA4\u5019\u9009\uFF0C\u518D\u8003\u8651\u662F\u5426\u9700\u8981\u8BFB\u53D6\u66F4\u591A\u4EE3\u7801\uFF08\u63D0\u4EA4\u4F18\u5148\u4E8E\u9A8C\u8BC1\uFF09";
|
|
66
66
|
export declare const PRODUCER_TOOLS: string[];
|
|
67
67
|
export declare const PRODUCER_BUDGET: {
|
|
68
68
|
maxIterations: number;
|
|
@@ -79,6 +79,29 @@ export declare const PRODUCER_BUDGET: {
|
|
|
79
79
|
* @param projectInfo { name }
|
|
80
80
|
*/
|
|
81
81
|
export declare function buildProducerPrompt(analysisReport: AnalysisReportLike, dimConfig: DimConfig, projectInfo: ProjectInfo): string;
|
|
82
|
+
/** Panorama context for Producer */
|
|
83
|
+
interface ProducerPanoramaContext {
|
|
84
|
+
moduleRole: string | null;
|
|
85
|
+
moduleLayer: number | null;
|
|
86
|
+
knownGaps: string[];
|
|
87
|
+
layerContext: string | null;
|
|
88
|
+
}
|
|
89
|
+
/** Rescan context for Producer — gap info + existing recipe titles */
|
|
90
|
+
interface ProducerRescanContext {
|
|
91
|
+
existingRecipes: Array<{
|
|
92
|
+
title: string;
|
|
93
|
+
trigger: string;
|
|
94
|
+
}>;
|
|
95
|
+
decayingRecipes?: Array<{
|
|
96
|
+
id?: string;
|
|
97
|
+
title: string;
|
|
98
|
+
trigger: string;
|
|
99
|
+
decayReason?: string;
|
|
100
|
+
}>;
|
|
101
|
+
occupiedTriggers: string[];
|
|
102
|
+
gap: number;
|
|
103
|
+
existing: number;
|
|
104
|
+
}
|
|
82
105
|
/**
|
|
83
106
|
* 构建 Producer Prompt v2 — 用于 AnalysisArtifact
|
|
84
107
|
*
|
|
@@ -86,8 +109,10 @@ export declare function buildProducerPrompt(analysisReport: AnalysisReportLike,
|
|
|
86
109
|
* - §3 结构化发现 (findings)
|
|
87
110
|
* - §4 代码证据 (evidenceMap → code context)
|
|
88
111
|
* - §5 负空间信号
|
|
112
|
+
* - §9 (可选) Rescan 模式约束
|
|
113
|
+
* - §M1 (可选) 全景上下文
|
|
89
114
|
*/
|
|
90
|
-
export declare function buildProducerPromptV2(artifact: AnalysisArtifactLike, dimConfig: DimConfig, projectInfo: ProjectInfo): string;
|
|
115
|
+
export declare function buildProducerPromptV2(artifact: AnalysisArtifactLike, dimConfig: DimConfig, projectInfo: ProjectInfo, rescanContext?: ProducerRescanContext | null, panorama?: ProducerPanoramaContext | null): string;
|
|
91
116
|
/**
|
|
92
117
|
* 从 evidenceMap 构建代码上下文段
|
|
93
118
|
*
|